You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
dotfiles/emacs

436 lines
15 KiB

(require 'package)
;; fixing broken emacsclient config: emacsclient --eval "(load "~/.emacs")"
(add-to-list 'package-archives '("elpa" . "https://tromey.com/elpa/") t)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("xaldew" . "https://gustafwaldemarson.com/elpa/"))
(add-to-list 'package-unsigned-archives "xaldew")
(package-initialize)
;; emacs preferences
(setq-default cursor-type 'bar)
(global-hl-line-mode 1)
(toggle-scroll-bar -1)
(menu-bar-mode -1)
(tool-bar-mode -1)
(column-number-mode t)
(set-fringe-mode 10)
(setq doc-view-scale-internally nil)
(setq visible-bell t)
(setq vc-handled-backends nil)
(setf epa-pinentry-mode 'loopback)
;; only show line numbers in programming mode
(defun display-numbers-hook ()
(display-line-numbers-mode t))
(add-hook 'prog-mode-hook 'display-numbers-hook)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file 'noerror)
(setq interprogram-cut-function nil)
(setq backup-directory-alist '(("" . "~/.emacs.d/backup")))
(setq package-check-signature nil)
(defun ensure-package-installed (&rest packages)
"Assure every package is installed, ask for installation if it’s not.
Return a list of installed packages or nil for every skipped package."
(mapcar
(lambda (package)
;; (package-installed-p 'evil)
(if (package-installed-p package)
nil
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package)
package)))
packages))
;; make sure to have downloaded archive description.
;; Or use package-archive-contents as suggested by Nicolas Dudebout
(or (file-exists-p package-user-dir)
(package-refresh-contents))
(ensure-package-installed 'use-package 'ivy 'magit 'centaur-tabs 'eglot 'dashboard 'multiple-cursors 'flycheck 'which-key 'doom-themes 'rainbow-mode 'rainbow-delimiters 'all-the-icons 'elpy 'rustic 'simpleclip 'messages-are-flowing 'hl-todo 'powerline 'format-all 'auctex 'counsel 'swiper 'projectile 'org-roam 'smex 'smartparens 'origami 'dumb-jump 'kaolin-themes 'company-quickhelp 'treemacs 'treemacs-projectile 'treemacs-magit 'treemacs-icons-dired 'org-mime 'hydra 'verb 'telephone-line 'bm 'undo-fu 'ranger)
;; need it after installation - makes it possible to bootstrap
(eval-when-compile
(require 'use-package))
(use-package ranger
:config
(setq ranger-preview-file nil)
(ranger-override-dired-mode t))
(use-package undo-fu
:config
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-z") 'undo-fu-only-undo)
(global-set-key (kbd "C-S-z") 'undo-fu-only-redo))
(use-package telephone-line
:init
(setq telephone-line-primary-left-separator 'telephone-line-cubed-left
telephone-line-secondary-left-separator 'telephone-line-cubed-hollow-left
telephone-line-primary-right-separator 'telephone-line-cubed-right
telephone-line-secondary-right-separator 'telephone-line-cubed-hollow-right)
(setq telephone-line-height 24)
:config
(telephone-line-mode 1))
(use-package magit
:ensure t)
(use-package treemacs
:ensure t
:defer t
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
:config
(progn
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display t
treemacs-file-event-delay 5000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch t
treemacs-silent-refresh t
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-wide-toggle-width 70
treemacs-width 35
treemacs-width-increment 1
treemacs-width-is-initially-locked t
treemacs-workspace-switch-cleanup nil)
;; The default width and height of the icons is 22 pixels. If you are
;; using a Hi-DPI display, uncomment this to double the icon size.
;;(treemacs-resize-icons 44)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(treemacs-git-mode 'deferred))
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("<f8>" . treemacs)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-projectile
:after (treemacs projectile)
:ensure t)
(use-package treemacs-icons-dired
:hook (dired-mode . treemacs-icons-dired-enable-once)
:ensure t)
(use-package treemacs-magit
:after (treemacs magit)
:ensure t)
(use-package bm
:ensure t
:demand t
:init
;; restore on load (even before you require bm)
(setq bm-restore-repository-on-load t)
:config
;; Allow cross-buffer 'next'
(setq bm-cycle-all-buffers t)
;; where to store persistant files
(setq bm-repository-file "~/.emacs.d/bm-repository")
;; save bookmarks
(setq-default bm-buffer-persistence t)
;; Loading the repository from file when on start up.
(add-hook 'after-init-hook 'bm-repository-load)
;; Saving bookmarks
(add-hook 'kill-buffer-hook #'bm-buffer-save)
;; Saving the repository to file when on exit.
;; kill-buffer-hook is not called when Emacs is killed, so we
;; must save all bookmarks first.
(add-hook 'kill-emacs-hook #'(lambda nil
(bm-buffer-save-all)
(bm-repository-save)))
;; The `after-save-hook' is not necessary to use to achieve persistence,
;; but it makes the bookmark data in repository more in sync with the file
;; state.
(add-hook 'after-save-hook #'bm-buffer-save)
;; Restoring bookmarks
(add-hook 'find-file-hooks #'bm-buffer-restore)
(add-hook 'after-revert-hook #'bm-buffer-restore)
;; The `after-revert-hook' is not necessary to use to achieve persistence,
;; but it makes the bookmark data in repository more in sync with the file
;; state. This hook might cause trouble when using packages
;; that automatically reverts the buffer (like vc after a check-in).
;; This can easily be avoided if the package provides a hook that is
;; called before the buffer is reverted (like `vc-before-checkin-hook').
;; Then new bookmarks can be saved before the buffer is reverted.
;; Make sure bookmarks is saved before check-in (and revert-buffer)
(add-hook 'vc-before-checkin-hook #'bm-buffer-save)
:bind (("<f2>" . bm-next)
("S-<f2>" . bm-previous)
("C-<f2>" . bm-toggle))
)
(global-set-key (kbd "<left-fringe> <mouse-5>") 'bm-next-mouse)
(global-set-key (kbd "<left-fringe> <mouse-4>") 'bm-previous-mouse)
(global-set-key (kbd "<left-fringe> <mouse-1>") 'bm-toggle-mouse)
(use-package dumb-jump)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
(setq xref-show-definitions-function #'xref-show-definitions-completing-read)
(use-package origami)
(bind-keys
:map origami-mode-map
("C-c C-<tab>" . origami-toggle-node))
(add-hook 'prog-mode-hook #'origami-mode)
(use-package smartparens-config
:config
(add-hook 'prog-mode-hook #'smartparens-mode))
(bind-keys
:map smartparens-mode-map
("C-M-a" . sp-beginning-of-sexp)
("C-M-e" . sp-end-of-sexp)
("C-<down>" . sp-down-sexp)
("C-<up>" . sp-up-sexp)
("M-<down>" . sp-backward-down-sexp)
("M-<up>" . sp-backward-up-sexp)
("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-n" . sp-next-sexp)
("C-M-p" . sp-previous-sexp)
("C-S-f" . sp-forward-symbol)
("C-S-b" . sp-backward-symbol)
("C-<right>" . sp-forward-slurp-sexp)
("M-<right>" . sp-forward-barf-sexp)
("C-<left>" . sp-backward-slurp-sexp)
("M-<left>" . sp-backward-barf-sexp)
("C-M-t" . sp-transpose-sexp)
("C-M-k" . sp-kill-sexp)
("C-k" . sp-kill-hybrid-sexp)
("M-k" . sp-backward-kill-sexp)
("C-M-w" . sp-copy-sexp)
("C-M-d" . delete-sexp)
("M-<backspace>" . backward-kill-word)
("C-<backspace>" . sp-backward-kill-word)
([remap sp-backward-kill-word] . backward-kill-word)
("M-[" . sp-backward-unwrap-sexp)
("M-]" . sp-unwrap-sexp)
("C-x C-t" . sp-transpose-hybrid-sexp)
("C-c (" . wrap-with-parens)
("C-c [" . wrap-with-brackets)
("C-c {" . wrap-with-braces)
("C-c '" . wrap-with-single-quotes)
("C-c \"" . wrap-with-double-quotes)
("C-c _" . wrap-with-underscores)
("C-c `" . wrap-with-back-quotes))
(use-package company)
(add-hook 'after-init-hook 'global-company-mode)
(company-quickhelp-mode)
(use-package eglot :ensure t)
(add-hook 'c++-mode-hook 'eglot-ensure)
(add-hook 'c-mode-hook 'eglot-ensure)
(add-hook 'js-mode-hook 'eglot-ensure)
(use-package centaur-tabs :init
(setq centaur-tabs-enable-key-bindings t
centaur-tabs-set-icons t
centaur-tabs-set-modified-marker t
centaur-tabs-style "chamfer"
centaur-tabs-gray-out-icons 'buffer))
;;(centaur-tabs-group-by-projectile-project) breaks w/ buffers unrelated to projects
(centaur-tabs-headline-match)
(centaur-tabs-mode 1)
(use-package flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
(add-hook 'css-mode-hook #'rainbow-mode)
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
(use-package which-key
:config
(which-key-mode))
(use-package dashboard
:init
(setq dashboard-set-footer nil
dashboard-org-agenda-categories '("Tasks" "appointments")
dashboard-center-content t
dashboard-set-heading-icons t
dashboard-set-file-icons t)
:ensure t
:config (dashboard-setup-startup-hook))
(use-package multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(use-package elpy
:ensure t
:defer t
:init
(advice-add 'python-mode :before 'elpy-enable)
:config
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))
(use-package ivy :ensure t
:diminish ivy-mode
:init (setq projectile-completion-system 'ivy)
:config
(ivy-mode 1)
(setq ivy-height 13)
(setq ivy-wrap t)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) "))
(use-package counsel
:ensure t
:bind*
(("M-x" . counsel-M-x)
("C-c d d" . counsel-descbinds)
("C-c s s" . counsel-ag)
("C-c s d" . counsel-ag-projectile)
("C-x C-f" . counsel-find-file)
("C-x r f" . counsel-recentf)
("C-c g g" . counsel-git)
("C-c g G" . counsel-git-grep)
("C-x l" . counsel-locate)
("C-c g s" . counsel-grep-or-swiper)
("C-M-y" . counsel-yank-pop)
("C-c C-r" . ivy-resume)
("C-c i m" . counsel-imenu)
("C-c i M" . ivy-imenu-anywhere)
("C-c d s" . describe-symbol)))
(use-package swiper
:bind*
(("C-s" . swiper)))
(setq search-default-mode #'char-fold-to-regexp)
(use-package projectile
:ensure t
:init
(projectile-mode +1)
:bind (:map projectile-mode-map
("s-p" . projectile-command-map)
("C-c p" . projectile-command-map)))
(setq projectile-sort-order 'recentf)
(setq projectile-require-project-root t)
(setq projectile-completion-system 'ivy)
;; org settings
(use-package org
:mode ("\\.org\\'" . org-mode)
:config (define-key org-mode-map (kbd "C-c C-r") verb-command-map))
(setq org-replace-disputed-keys t)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
(setq org-log-done t)
(setq org-startup-with-inline-images t)
(setq org-startup-with-latex-preview t)
(setq-default org-display-custom-times t)
(setq org-time-stamp-custom-formats '("<%a %b %e %Y>" . "<%a %b %e %Y %H:%M>"))
; agenda settings
(setq org-agenda-include-diary t)
(setq org-agenda-skip-scheduled-if-done t)
(setq org-agenda-skip-deadline-if-done t)
(setq org-agenda-todo-ignore-deadlines t)
(setq org-agenda-todo-ignore-with-date t)
(setq org-agenda-todo-ignore-scheduled t)
(setq org-agenda-start-on-weekday nil)
(setq org-agenda-start-day "+0d")
(add-hook 'diary-list-entries-hook 'diary-sort-entries t)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
(cond ((file-exists-p "~/.emacs_home.el") (load "~/.emacs_home.el")))
(cond ((file-exists-p "~/.emacs_work.el") (load "~/.emacs_work.el")))
;;; .emacs ends here