diff --git a/home/emacs/default.nix b/home/emacs/default.nix index 6d0df410..42ee8b8f 100644 --- a/home/emacs/default.nix +++ b/home/emacs/default.nix @@ -13,7 +13,6 @@ with epkgs; [ # themes modus-themes - doom-themes tron-legacy-theme # completion-packages diff --git a/home/emacs/init.el b/home/emacs/init.el index 7e064c93..e38a9103 100644 --- a/home/emacs/init.el +++ b/home/emacs/init.el @@ -74,6 +74,13 @@ ;; Bind extra `describe-*' commands (keymap-global-set "C-h K" #'describe-keymap) +(use-package link-hint + :ensure t + :bind (("C-c l o" . link-hint-open-link) + ("C-c l c" . link-hint-copy-link) + ("C-c l C-o" . link-hint-open-all-link) + ("C-c l C-c" . link-hint-copy-all-link))) + (setq use-dialog-box nil fill-column 80 truncate-lines nil @@ -121,14 +128,16 @@ :ensure t :config (nerd-icons-set-font "Symbols Nerd Font Mono")) +(use-package nerd-icons-dired + :ensure t + :hook (dired-mode)) + (use-package nerd-icons-ibuffer :ensure t - :hook dired-mode) + :hook (ibuffer-mode)) (use-package nerd-icons-completion :ensure t - :requires marginalia - :hook marginalia-mode :config (nerd-icons-completion-mode +1)) (use-package ligature @@ -256,6 +265,7 @@ org-refile-targets '((nil :maxlevel . 3) (org-agenda-files :maxlevel . 3))) +(keymap-global-set "C-c o e" #'org-edit-src-code) (keymap-global-set "C-c o a" #'org-agenda) (keymap-global-set "C-c o n" #'org-capture) (keymap-global-set "C-c o l" #'org-capture-goto-last-stored) @@ -316,6 +326,61 @@ (add-hook 'org-agenda-mode-hook #'khalel-import-events) (khalel-add-capture-template "e")) +(use-package rainbow-delimiters + :ensure t + :hook (prog-mode)) + +(setq apheleia-remote-algorithm 'local) +(use-package apheleia + :ensure t + :defer nil + :bind (("C-c c f" . apheleia-format-buffer)) + :config (apheleia-global-mode +1)) + +(use-package ibuffer-project + :ensure t + :hook ((ibuffer . (lambda () + (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups)) + (unless (eq ibuffer-sorting-mode 'project-file-relative) + (ibuffer-do-sort-by-project-file-relative)))))) + +(use-package treesit-auto + :config (global-treesit-auto-mode +1)) + +(setq direnv-always-show-summary nil) +(use-package direnv + :config (direnv-mode +1)) + +;;; Eglot +(defun crafted-ide--add-eglot-hooks (mode-list) + "Add `eglot-ensure' to modes in MODE-LIST. + +The mode must be loaded, i.e. found with `fboundp'. A mode which +is not loaded will not have a hook added, in which case add it +manually with something like this: + +`(add-hook 'some-mode-hook #'eglot-ensure)'" + (dolist (mode-def mode-list) + (let ((mode (if (listp mode-def) (car mode-def) mode-def))) + (cond + ((listp mode) (crafted-ide--add-eglot-hooks mode)) + (t + (when (and (fboundp mode) + (not (eq 'clojure-mode mode)) ; prefer cider + (not (eq 'lisp-mode mode)) ; prefer sly/slime + (not (eq 'scheme-mode mode)) ; prefer geiser + ) + (let ((hook-name (format "%s-hook" (symbol-name mode)))) + (message "adding eglot to %s" hook-name) + (add-hook (intern hook-name) #'eglot-ensure)))))))) + +;; add eglot to existing programming modes when eglot is loaded. +(with-eval-after-load "eglot" + (crafted-ide--add-eglot-hooks eglot-server-programs)) + +;; Shutdown server when last managed buffer is killed +(customize-set-variable 'eglot-autoshutdown t) + (setq sendmail-program (executable-find "msmtp") send-mail-function #'smtpmail-send-it message-sendmail-f-is-evil t @@ -415,88 +480,6 @@ (when (require 'elfeed-tube nil :noerror) (elfeed-tube-setup))) -(when (require 'rainbow-delimiters nil :noerror) - (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)) - -(when (require 'treesit-aut nil :noerror) - (global-treesit-auto-mode +1)) - -(setq apheleia-remote-algorithm 'local) -(when (require 'apheleia nil :noerror) - (keymap-global-set "C-c c f" #'apheleia-format-buffer) - (apheleia-global-mode +1)) - -(when (require 'eglot nil :noerror) - (eglot-ensure)) - -(setq direnv-always-show-summary nil) -(when (require 'direnv nil :noerror) - (direnv-mode +1)) - -(when (require 'yasnippet nil :noerror) - (require 'yasnippet-snippets nil :noerror) - (yas-reload-all) - (add-hook 'prog-mode-hook #'yas-minor-mode)) - -(defun fira-code-mode--make-alist (list) - "Generate prettify-symbols alist from LIST." - (let ((idx -1)) - (mapcar - (lambda (s) - (setq idx (1+ idx)) - (let* ((code (+ #Xe100 idx)) - (width (string-width s)) - (prefix ()) - (suffix '(?\s (Br . Br))) - (n 1)) - (while (< n width) - (setq prefix (append prefix '(?\s (Br . Bl)))) - (setq n (1+ n))) - (cons s (append prefix suffix (list (decode-char 'ucs code)))))) - list))) - -(defconst fira-code-mode--ligatures - '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" - "{-" "[]" "::" ":::" ":=" "!!" "!=" "!==" "-}" - "--" "---" "-->" "->" "->>" "-<" "-<<" "-~" - "#{" "#[" "##" "###" "####" "#(" "#?" "#_" "#_(" - ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" - "/**" "/=" "/==" "/>" "//" "///" "&&" "||" "||=" - "|=" "|>" "^=" "$>" "++" "+++" "+>" "=:=" "==" - "===" "==>" "=>" "=>>" "<=" "=<<" "=/=" ">-" ">=" - ">=>" ">>" ">>-" ">>=" ">>>" "<*" "<*>" "<|" "<|>" - "<$" "<$>" "