Convert IDE config
Add keymaps for common link-hint commands Remove some now unused packages
This commit is contained in:
parent
110df66ad2
commit
ea83dccc15
|
@ -14,7 +14,6 @@
|
||||||
# themes
|
# themes
|
||||||
modus-themes
|
modus-themes
|
||||||
doom-themes
|
doom-themes
|
||||||
base16-theme
|
|
||||||
tron-legacy-theme
|
tron-legacy-theme
|
||||||
|
|
||||||
# completion-packages
|
# completion-packages
|
||||||
|
@ -29,8 +28,6 @@
|
||||||
vertico
|
vertico
|
||||||
|
|
||||||
# ide-packages
|
# ide-packages
|
||||||
editorconfig
|
|
||||||
aggressive-indent
|
|
||||||
ibuffer-project
|
ibuffer-project
|
||||||
treesit-grammars.with-all-grammars
|
treesit-grammars.with-all-grammars
|
||||||
treesit-auto
|
treesit-auto
|
||||||
|
@ -38,8 +35,6 @@
|
||||||
direnv
|
direnv
|
||||||
goto-chg
|
goto-chg
|
||||||
rainbow-delimiters
|
rainbow-delimiters
|
||||||
yasnippet
|
|
||||||
yasnippet-snippets
|
|
||||||
nix-mode
|
nix-mode
|
||||||
rust-mode
|
rust-mode
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,15 @@
|
||||||
(keymap-global-set "C-h K" #'describe-keymap)
|
(keymap-global-set "C-h K" #'describe-keymap)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Link hint keymaps
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(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)))
|
||||||
|
#+end_src
|
||||||
* UI
|
* UI
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(setq use-dialog-box nil
|
(setq use-dialog-box nil
|
||||||
|
@ -373,6 +382,66 @@ For reference information, see [[https://orgmode.com][Org-mode website]]
|
||||||
(add-hook 'org-agenda-mode-hook #'khalel-import-events)
|
(add-hook 'org-agenda-mode-hook #'khalel-import-events)
|
||||||
(khalel-add-capture-template "e"))
|
(khalel-add-capture-template "e"))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
* Development Environment
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(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))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Eglot LSP
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
;;; 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)
|
||||||
|
#+END_SRC
|
||||||
* Copy (to sort)
|
* Copy (to sort)
|
||||||
For now I'll just copy all config into this file, to confirm that it works properly.
|
For now I'll just copy all config into this file, to confirm that it works properly.
|
||||||
Will reorganise into separate sections later
|
Will reorganise into separate sections later
|
||||||
|
@ -483,32 +552,6 @@ Will reorganise into separate sections later
|
||||||
(elfeed-tube-setup)))
|
(elfeed-tube-setup)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** TODO IDE
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(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))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** TODO Media
|
** TODO Media
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(when (require 'emms-setup nil :noerror)
|
(when (require 'emms-setup nil :noerror)
|
||||||
|
@ -662,101 +705,6 @@ Will reorganise into separate sections later
|
||||||
(add-hook 'eshell-mode-hook #'crafted-completion-corfu-eshell))
|
(add-hook 'eshell-mode-hook #'crafted-completion-corfu-eshell))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** TODO IDE (Crafted)
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
;;; 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)
|
|
||||||
|
|
||||||
;;; tree-sitter
|
|
||||||
(defun crafted-ide--configure-tree-sitter-pre-29 ()
|
|
||||||
"Configure tree-sitter for Emacs 28 or earlier."
|
|
||||||
|
|
||||||
(defun crafted-tree-sitter-load (lang-symbol)
|
|
||||||
"Setup tree-sitter for a language.
|
|
||||||
|
|
||||||
This must be called in the user's configuration to configure
|
|
||||||
tree-sitter for LANG-SYMBOL.
|
|
||||||
|
|
||||||
Example: `(crafted-tree-sitter-load 'python)'"
|
|
||||||
(tree-sitter-require lang-symbol)
|
|
||||||
(let ((mode-hook-name
|
|
||||||
(intern (format "%s-mode-hook" (symbol-name lang-symbol)))))
|
|
||||||
(add-hook mode-hook-name #'tree-sitter-mode))))
|
|
||||||
|
|
||||||
(defun crafted-ide--configure-tree-sitter (opt-out)
|
|
||||||
"Configure tree-sitter for Emacs 29 or later.
|
|
||||||
OPT-OUT is a list of symbols of language grammars to opt out before auto-install."
|
|
||||||
;; only attempt to use tree-sitter when Emacs was built with it.
|
|
||||||
(when (member "TREE_SITTER" (split-string system-configuration-features))
|
|
||||||
(when (require 'treesit-auto nil :noerror)
|
|
||||||
;; add all items of opt-out to the `treesit-auto-opt-out-list'.
|
|
||||||
(when opt-out
|
|
||||||
(mapc (lambda (e) (add-to-list 'treesit-auto-opt-out-list e)) opt-out))
|
|
||||||
;; prefer tree-sitter modes
|
|
||||||
(global-treesit-auto-mode)
|
|
||||||
;; install all the tree-sitter grammars
|
|
||||||
(treesit-auto-install-all)
|
|
||||||
;; configure `auto-mode-alist' for tree-sitter modes relying on
|
|
||||||
;; `fundamental-mode'
|
|
||||||
(treesit-auto-add-to-auto-mode-alist))
|
|
||||||
(when (locate-library "combobulate")
|
|
||||||
;; perhaps too gross of an application, but the *-ts-modes
|
|
||||||
;; eventually derive from this mode.
|
|
||||||
(add-hook 'prog-mode-hook #'combobulate-mode))))
|
|
||||||
|
|
||||||
(defun crafted-ide-configure-tree-sitter (&optional opt-out)
|
|
||||||
"Configure tree-sitter.
|
|
||||||
Requires a C compiler (gcc, cc, c99) installed on the system.
|
|
||||||
Note that OPT-OUT only affects setups with Emacs 29 or later.
|
|
||||||
|
|
||||||
For Emacs 29 or later:
|
|
||||||
Requires Emacs to be built using \"--with-tree-sitter\".
|
|
||||||
All language grammars are auto-installed unless they are a member of OPT-OUT."
|
|
||||||
(if (version< emacs-version "29")
|
|
||||||
(crafted-ide--configure-tree-sitter-pre-29)
|
|
||||||
(crafted-ide--configure-tree-sitter opt-out)))
|
|
||||||
|
|
||||||
;; turn on editorconfig if it is available
|
|
||||||
(when (require 'editorconfig nil :noerror)
|
|
||||||
(add-hook 'prog-mode-hook #'editorconfig-mode))
|
|
||||||
|
|
||||||
;; enhance ibuffer with ibuffer-project if it is available.
|
|
||||||
(when (require 'ibuffer-project nil :noerror)
|
|
||||||
(defun crafted-ide-enhance-ibuffer-with-ibuffer-project ()
|
|
||||||
"Set up integration for `ibuffer' with `ibuffer-project'."
|
|
||||||
(setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups))
|
|
||||||
(unless (eq ibuffer-sorting-mode 'project-file-relative)
|
|
||||||
(ibuffer-do-sort-by-project-file-relative)))
|
|
||||||
(add-hook 'ibuffer-hook #'crafted-ide-enhance-ibuffer-with-ibuffer-project))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** TODO Org (Crafted)
|
** TODO Org (Crafted)
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
;; Return or left-click with mouse follows link
|
;; Return or left-click with mouse follows link
|
||||||
|
|
Loading…
Reference in a new issue