emacs: Giving eglot another go
This commit is contained in:
parent
349f8cdb87
commit
08afcf25c8
1 changed files with 111 additions and 51 deletions
|
@ -905,11 +905,11 @@ Visualise git changes in the gutter, next to the line numbers
|
||||||
:after tree-sitter)
|
:after tree-sitter)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** LSP
|
*** lsp-mode
|
||||||
|
|
||||||
[[https://emacs-lsp.github.io/lsp-mode][lsp-mode]] adds Language Server Protocol support to emacs.
|
[[https://emacs-lsp.github.io/lsp-mode][lsp-mode]] adds Language Server Protocol support to emacs.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package lsp-mode
|
(use-package lsp-mode
|
||||||
:init
|
:init
|
||||||
(setq lsp-keymap-prefix "C-c l"
|
(setq lsp-keymap-prefix "C-c l"
|
||||||
|
@ -934,7 +934,7 @@ Visualise git changes in the gutter, next to the line numbers
|
||||||
|
|
||||||
[[https://emacs-lsp.github.io/lsp-ui/][lsp-ui]] provides higher level UI elements for =lsp-mode=, like code lenses and flycheck support.
|
[[https://emacs-lsp.github.io/lsp-ui/][lsp-ui]] provides higher level UI elements for =lsp-mode=, like code lenses and flycheck support.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package lsp-ui
|
(use-package lsp-ui
|
||||||
:ghook 'lsp-mode-hook
|
:ghook 'lsp-mode-hook
|
||||||
:config
|
:config
|
||||||
|
@ -955,22 +955,22 @@ Visualise git changes in the gutter, next to the line numbers
|
||||||
|
|
||||||
[[https://github.com/gagbo/consult-lsp][consult-lsp]] integrates =consult= into =lsp-mode=
|
[[https://github.com/gagbo/consult-lsp][consult-lsp]] integrates =consult= into =lsp-mode=
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package consult-lsp)
|
(use-package consult-lsp)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
[[https://github.com/emacs-lsp/lsp-treemacs][lsp-treemacs]] provides an integration between =lsp-mode= and [[https://github.com/Alexander-Miller/treemacs][treemacs]].
|
[[https://github.com/emacs-lsp/lsp-treemacs][lsp-treemacs]] provides an integration between =lsp-mode= and [[https://github.com/Alexander-Miller/treemacs][treemacs]].
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package lsp-treemacs
|
(use-package lsp-treemacs
|
||||||
:commands lsp-treemacs-errors-list)
|
:commands lsp-treemacs-errors-list)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** DAP
|
*** dap-mode
|
||||||
|
|
||||||
[[http://emacs-lsp.github.io/dap-mode][dap-mode]] provides debugging facilities using the [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]]
|
[[http://emacs-lsp.github.io/dap-mode][dap-mode]] provides debugging facilities using the [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]]
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package dap-mode
|
(use-package dap-mode
|
||||||
:defer t
|
:defer t
|
||||||
:custom
|
:custom
|
||||||
|
@ -998,6 +998,35 @@ Visualise git changes in the gutter, next to the line numbers
|
||||||
(find-file-existing filename))))
|
(find-file-existing filename))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
*** eglot
|
||||||
|
|
||||||
|
[[https://joaotavora.github.io/eglot/][eglot]] is an alternative to =lsp-mode= that is builtin with emacs >= 29
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package eglot
|
||||||
|
:config
|
||||||
|
(add-to-list 'eglot-server-programs
|
||||||
|
'(conf-toml-mode . ("taplo" "lsp" "stdio"))
|
||||||
|
'(elixir-mode elixir-ts-mode heex-ts-mode . ("elixir-ls")))
|
||||||
|
(setq eglot-autoshutdown t))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
[[https://github.com/nemethf/eglot-x][eglot-x]] adds support for some LSP extensions to =eglot=
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp :tangle no
|
||||||
|
(use-package eglot-x
|
||||||
|
:vc (:fetcher github :repo nemethf/eglot-x)
|
||||||
|
:after eglot
|
||||||
|
:config
|
||||||
|
(eglot-x-setup))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
[[https://github.com/mohkale/consult-eglot][consult-eglot]] adds an integration between =consult= and =eglot=
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package consult-eglot)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** Snippets
|
** Snippets
|
||||||
|
|
||||||
Snippets are predefined pieces of code that can be inserted and filled in. [[https://github.com/joaotavora/yasnippet][YASnippet]] uses syntax inspired by TextMate is the most popular, for good reason.
|
Snippets are predefined pieces of code that can be inserted and filled in. [[https://github.com/joaotavora/yasnippet][YASnippet]] uses syntax inspired by TextMate is the most popular, for good reason.
|
||||||
|
@ -1034,13 +1063,13 @@ Indent 2 spaces
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package js2-mode
|
(use-package js2-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:mode
|
:mode
|
||||||
("\\.mjs\\'" . js2-mode)
|
("\\.mjs\\'" . js2-mode)
|
||||||
("\\.jsx?\\'" . js2-jsx-mode)
|
("\\.jsx?\\'" . js2-jsx-mode)
|
||||||
:hook
|
:hook
|
||||||
(js2-mode . lsp-deferred)
|
(js2-mode . eglot-ensure)
|
||||||
(js2-jsx-mode . lsp-deferred))
|
(js2-jsx-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Prettier has my preference for formatting JavaScript and TypeScript
|
Prettier has my preference for formatting JavaScript and TypeScript
|
||||||
|
@ -1057,10 +1086,10 @@ TypeScript stuff
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package typescript-mode
|
(use-package typescript-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:mode
|
:mode
|
||||||
("\\.tsx?\\'" . typescript-mode)
|
("\\.tsx?\\'" . typescript-mode)
|
||||||
:hook (typescript-mode . lsp-deferred))
|
:hook (typescript-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Prefer local packages from =node_modules= to global ones
|
Prefer local packages from =node_modules= to global ones
|
||||||
|
@ -1075,7 +1104,7 @@ Prefer local packages from =node_modules= to global ones
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package web-mode
|
(use-package web-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:config
|
:config
|
||||||
(setq web-mode-markup-indent-offset 2
|
(setq web-mode-markup-indent-offset 2
|
||||||
web-mode-css-indent-offset 2
|
web-mode-css-indent-offset 2
|
||||||
|
@ -1087,7 +1116,7 @@ Prefer local packages from =node_modules= to global ones
|
||||||
|
|
||||||
(add-to-list 'web-mode-engines-alist '(("elixir" . "\\.html.heex\\'")))
|
(add-to-list 'web-mode-engines-alist '(("elixir" . "\\.html.heex\\'")))
|
||||||
:hook
|
:hook
|
||||||
((html-mode css-mode web-mode) . lsp-deferred))
|
((html-mode css-mode web-mode) . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Markdown
|
*** Markdown
|
||||||
|
@ -1096,7 +1125,7 @@ Prefer local packages from =node_modules= to global ones
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package markdown-mode
|
(use-package markdown-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:mode
|
:mode
|
||||||
(("README\\.md\\'" . gfm-mode)
|
(("README\\.md\\'" . gfm-mode)
|
||||||
("\\.md\\'" . markdown-mode)
|
("\\.md\\'" . markdown-mode)
|
||||||
|
@ -1105,7 +1134,7 @@ Prefer local packages from =node_modules= to global ones
|
||||||
(setq markdown-command "multimarkdown")
|
(setq markdown-command "multimarkdown")
|
||||||
:hook
|
:hook
|
||||||
(markdown-mode . display-fill-column-indicator-mode)
|
(markdown-mode . display-fill-column-indicator-mode)
|
||||||
(markdown-mode . lsp-deferred))
|
(markdown-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
[[https://github.com/skeeto/impatient-mode][impatient-mode]] live renders HTML, but it can be made to work with Markdown with a custom filter
|
[[https://github.com/skeeto/impatient-mode][impatient-mode]] live renders HTML, but it can be made to work with Markdown with a custom filter
|
||||||
|
@ -1132,7 +1161,7 @@ Add support for Elixir with [[https://github.com/elixir-editors/emacs-elixir][el
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package elixir-mode
|
(use-package elixir-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook ((elixir-format . (lambda ()
|
:hook ((elixir-format . (lambda ()
|
||||||
(if (projectile-project-p)
|
(if (projectile-project-p)
|
||||||
(setq elixir-format-arguments
|
(setq elixir-format-arguments
|
||||||
|
@ -1140,7 +1169,7 @@ Add support for Elixir with [[https://github.com/elixir-editors/emacs-elixir][el
|
||||||
(concat (locate-dominating-file buffer-file-name ".formatter.exs") ".formatter.exs")))
|
(concat (locate-dominating-file buffer-file-name ".formatter.exs") ".formatter.exs")))
|
||||||
(setq elixir-format-arguments nil))))
|
(setq elixir-format-arguments nil))))
|
||||||
(elixir-mode . (lambda () (add-hook 'before-save-hook 'elixir-format nil t)))
|
(elixir-mode . (lambda () (add-hook 'before-save-hook 'elixir-format nil t)))
|
||||||
(elixir-mode . lsp-deferred))
|
(elixir-mode . eglot-ensure))
|
||||||
:config
|
:config
|
||||||
(setq lsp-elixir-server-command '("elixir-ls"))
|
(setq lsp-elixir-server-command '("elixir-ls"))
|
||||||
(add-to-list 'auto-mode-alist '("\\.[hl]eex\\'" . elixir-mode)))
|
(add-to-list 'auto-mode-alist '("\\.[hl]eex\\'" . elixir-mode)))
|
||||||
|
@ -1172,17 +1201,48 @@ Rust support with [[https://github.com/rust-lang/rust-mode][rust-mode]].
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package rust-mode
|
(use-package rust-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook
|
:hook
|
||||||
(rust-mode . lsp-deferred)
|
(rust-mode . eglot-ensure)
|
||||||
(rust-ts-mode . lsp-deferred)
|
(rust-ts-mode . eglot-ensure)
|
||||||
(before-save . lsp-format-buffer)
|
(before-save . eglot-format-buffer)
|
||||||
(before-save . lsp-organize-imports)
|
(before-save . eglot-code-action-organize-imports)
|
||||||
:init
|
;; :init
|
||||||
(setq lsp-rust-analyzer-cargo-watch-command "clippy"
|
;; (setq lsp-rust-analyzer-cargo-watch-command "clippy"
|
||||||
lsp-rust-analyzer-server-display-inlay-hints t
|
;; lsp-rust-analyzer-server-display-inlay-hints t
|
||||||
lsp-rust-analyzer-binding-mode-hints t
|
;; lsp-rust-analyzer-binding-mode-hints t
|
||||||
lsp-rust-analyzer-display-lifetime-elision-hints-enable "always"))
|
;; lsp-rust-analyzer-display-lifetime-elision-hints-enable "always")
|
||||||
|
)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Configure [[https://rust-analyzer.github.io][rust-analyzer]]
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun eb/ra-eglot-config (server)
|
||||||
|
"initializationOptions for rust-analyzer"
|
||||||
|
`(:diagnostics (:enable t)
|
||||||
|
:imports (:granularity (:enforce :json-false :group "crate")
|
||||||
|
:group t :merge
|
||||||
|
(:glob t)
|
||||||
|
:prefix "plain")
|
||||||
|
:lruCapacity nil
|
||||||
|
:checkOnSave (:enable t
|
||||||
|
:command "clippy"
|
||||||
|
:allTargets t)
|
||||||
|
:inlayHints (:bindingModeHints t
|
||||||
|
:chainingHints t
|
||||||
|
:lifetimeElisionHints (:enable "always" :useParameterNames :json-false)
|
||||||
|
:maxLength nil
|
||||||
|
:parameterHints :json-false
|
||||||
|
:renderColons t
|
||||||
|
:typeHints (:enable t
|
||||||
|
:hideClosureInitialization :json-false
|
||||||
|
:hideNamedConstructor :json-false))
|
||||||
|
:procMacro (:enable t)))
|
||||||
|
|
||||||
|
(with-eval-after-load 'eglot
|
||||||
|
(add-to-list 'eglot-server-programs
|
||||||
|
'(rust-mode . ("rust-analyzer" :initializationOptions eb/ra-eglot-config))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Add [[https://github.com/kwrooijen/cargo.el][cargo]] support
|
Add [[https://github.com/kwrooijen/cargo.el][cargo]] support
|
||||||
|
@ -1216,8 +1276,8 @@ Add docker support with [[https://github.com/spotify/dockerfile-mode][dockerfile
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package dockerfile-mode
|
(use-package dockerfile-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (dockerfile-mode . lsp-deferred))
|
:hook (dockerfile-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Bitbake / Yocto
|
*** Bitbake / Yocto
|
||||||
|
@ -1241,8 +1301,8 @@ Add docker support with [[https://github.com/spotify/dockerfile-mode][dockerfile
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package json-mode
|
(use-package json-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (json-mode . lsp-deferred))
|
:hook (json-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** CMake
|
*** CMake
|
||||||
|
@ -1251,8 +1311,8 @@ Add [[https://melpa.org/#/cmake-mode][cmake-mode]]
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package cmake-mode
|
(use-package cmake-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (cmake-mode . lsp-deferred))
|
:hook (cmake-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** YAML
|
*** YAML
|
||||||
|
@ -1261,8 +1321,8 @@ Use [[https://github.com/yoshiki/yaml-mode][yaml-mode]] to handle YAML files
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package yaml-mode
|
(use-package yaml-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (yaml-mode . lsp-deferred))
|
:hook (yaml-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** C/C++
|
*** C/C++
|
||||||
|
|
||||||
|
@ -1271,10 +1331,10 @@ Enable clangd LSP for C and C++
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package cc-mode
|
(use-package cc-mode
|
||||||
:ensure nil
|
:ensure nil
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook
|
:hook
|
||||||
(c-mode . lsp-deferred)
|
(c-mode . eglot-ensure)
|
||||||
(c++-mode . lsp-deferred))
|
(c++-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Enable and configure =auto-insert-mode= for Horus projects
|
Enable and configure =auto-insert-mode= for Horus projects
|
||||||
|
@ -1306,9 +1366,9 @@ Add [[https://github.com/NixOS/nix-mode][nix-mode]]
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package nix-mode
|
(use-package nix-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:mode "\\.nix\\'"
|
:mode "\\.nix\\'"
|
||||||
:hook (nix-mode . lsp-deferred))
|
:hook (nix-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Common Lisp
|
*** Common Lisp
|
||||||
|
@ -1342,8 +1402,8 @@ Similar to =lisp=, there is [[https://github.com/clojure-emacs/cider][CIDER]] (C
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package terraform-mode
|
(use-package terraform-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (terraform-mode . lsp-deferred))
|
:hook (terraform-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Fish
|
*** Fish
|
||||||
|
@ -1362,8 +1422,8 @@ Similar to =lisp=, there is [[https://github.com/clojure-emacs/cider][CIDER]] (C
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package zig-mode
|
(use-package zig-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (zig-mode . lsp-deferred))
|
:hook (zig-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Yuck
|
*** Yuck
|
||||||
|
@ -1376,8 +1436,8 @@ Similar to =lisp=, there is [[https://github.com/clojure-emacs/cider][CIDER]] (C
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package racket-mode
|
(use-package racket-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (racket-mode . lsp-deferred))
|
:hook (racket-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Ruby
|
*** Ruby
|
||||||
|
@ -1387,8 +1447,8 @@ Let =ruby-mode= handle Ruby files
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package ruby-mode
|
(use-package ruby-mode
|
||||||
:ensure nil
|
:ensure nil
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (ruby-mode . lsp-deferred))
|
:hook (ruby-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** MapServer
|
*** MapServer
|
||||||
|
@ -1407,8 +1467,8 @@ It's better than nothing.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package go-mode
|
(use-package go-mode
|
||||||
:after lsp-mode
|
:after eglot
|
||||||
:hook (go-mode . lsp-deferred))
|
:hook (go-mode . eglot-ensure))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Cucumber
|
*** Cucumber
|
||||||
|
|
Loading…
Reference in a new issue