try out eglot
This commit is contained in:
parent
5dfd74c940
commit
dbf14145df
115
init.org
115
init.org
|
@ -1122,7 +1122,7 @@ Use =vertico-posframe= to make the =vertico= buffer floating in the centre of th
|
||||||
(consult-ripgrep (:not posframe))
|
(consult-ripgrep (:not posframe))
|
||||||
(nemo/consult-ripgrep (:not posframe))
|
(nemo/consult-ripgrep (:not posframe))
|
||||||
(nemo/consult-ripgrep-dir (:not posframe))
|
(nemo/consult-ripgrep-dir (:not posframe))
|
||||||
(lsp-find-references (:not posframe))
|
;; (lsp-find-references (:not posframe))
|
||||||
(embark-act (:not posframe))
|
(embark-act (:not posframe))
|
||||||
(t posframe))
|
(t posframe))
|
||||||
))
|
))
|
||||||
|
@ -1233,16 +1233,14 @@ Auto-completion using =corfu=:
|
||||||
(corfu-on-exact-match nil)
|
(corfu-on-exact-match nil)
|
||||||
;; Don't automatically fill in the selected candidate
|
;; Don't automatically fill in the selected candidate
|
||||||
(corfu-preview-current nil)
|
(corfu-preview-current nil)
|
||||||
:custom
|
|
||||||
(lsp-completion-provider :none)
|
|
||||||
:init
|
:init
|
||||||
(defun nemo/orderless-dispatch-flex-first (_pattern index _total)
|
(defun nemo/orderless-dispatch-flex-first (_pattern index _total)
|
||||||
(and (eq index 0) 'orderless-flex))
|
(and (eq index 0) 'orderless-flex))
|
||||||
|
|
||||||
(defun nemo/lsp-mode-setup-completion ()
|
;; (defun nemo/lsp-mode-setup-completion ()
|
||||||
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) '(orderless))
|
;; (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) '(orderless))
|
||||||
(add-hook 'orderless-style-dispatchers #'nemo/orderless-dispatch-flex-first nil 'local))
|
;; (add-hook 'orderless-style-dispatchers #'nemo/orderless-dispatch-flex-first nil 'local))
|
||||||
:hook (lsp-completion-mode . nemo/lsp-mode-setup-completion)
|
;; :hook (lsp-completion-mode . nemo/lsp-mode-setup-completion)
|
||||||
:config
|
:config
|
||||||
(global-corfu-mode))
|
(global-corfu-mode))
|
||||||
|
|
||||||
|
@ -1602,7 +1600,95 @@ Auto-completion requires yasnippet for some competions, such as function argumen
|
||||||
:straight t)
|
:straight t)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** LSP
|
** Eglot
|
||||||
|
|
||||||
|
Use =eglot= as an alternative to =lsp-mode=:
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package eglot
|
||||||
|
:straight t
|
||||||
|
:hook ((rust-mode nix-mode prog-mode) . eglot-ensure)
|
||||||
|
:config
|
||||||
|
(add-to-list
|
||||||
|
'eglot-server-programs
|
||||||
|
`(rust-mode
|
||||||
|
. ("rust-analyzer" :initializationOptions
|
||||||
|
(:cargo (:buildScripts (:enable t)
|
||||||
|
:allFeatures t
|
||||||
|
:extraEnv (:RUSTFLAGS "-Clinker=clang -Clink-arg=-fuse-ld=mold")))
|
||||||
|
(:check (:command "clippy"))
|
||||||
|
(:completion (:autoimport t))
|
||||||
|
(:inlayHints (
|
||||||
|
;; :maxLength 20
|
||||||
|
:bindingModeHints t
|
||||||
|
:closureReturnTypeHints t))
|
||||||
|
(:procMacro (:enable t)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(setq eglot-code-action-indications '(margin mode-line)
|
||||||
|
eglot-extend-to-xref t
|
||||||
|
completion-category-overrides '((eglot (styles orderless))
|
||||||
|
(eglot-capf (styles orderless)))
|
||||||
|
)
|
||||||
|
(with-eval-after-load 'eglot
|
||||||
|
(setq completion-category-defaults nil))
|
||||||
|
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
|
||||||
|
:general-config
|
||||||
|
(general-define-key
|
||||||
|
:prefix-map 'nemo/eglot-command-map
|
||||||
|
"r r" '("Rename" . eglot-rename)
|
||||||
|
"a a" '("Code Action" . eglot-code-action-quickfix)
|
||||||
|
"a A" '("Code Action (all)" . eglot-code-actions)
|
||||||
|
"g d" '("Go to Definition" . xref-find-definitions)
|
||||||
|
"g r" '("Go to References" . xref-find-references)
|
||||||
|
"g g" '("Go to Declaration" . eglot-find-declaration)
|
||||||
|
"g i" '("Go to Implementation" . eglot-find-implementation)
|
||||||
|
"g t" '("Go to Type Definition" . eglot-find-typeDefinition)
|
||||||
|
"h h" '("Help" . eldoc-box-help-at-point)
|
||||||
|
"w r" '("Restart Server" . eglot-reconnect)
|
||||||
|
"w q" '("Shutdown Server" . eglot-shutdown)
|
||||||
|
"= =" '("Format Buffer" . eglot-format-buffer)
|
||||||
|
"= r" '("Format Region" . eglot-format-region)
|
||||||
|
)
|
||||||
|
(leader-major-def
|
||||||
|
:keymaps 'eglot-mode-map
|
||||||
|
"l" '(:keymap nemo/eglot-command-map :wk "Eglot")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(use-package eldoc-box
|
||||||
|
:straight t
|
||||||
|
:hook (eglot-managed-mode . eldoc-box-hover-mode)
|
||||||
|
:hook (eldoc-box-buffer . variable-pitch-mode)
|
||||||
|
:config
|
||||||
|
(setq eldoc-box-only-multi-line t)
|
||||||
|
)
|
||||||
|
|
||||||
|
(use-package consult-eglot
|
||||||
|
:straight t
|
||||||
|
:after (consult eglot)
|
||||||
|
:config
|
||||||
|
(general-define-key
|
||||||
|
:prefix-map 'nemo/eglot-command-map
|
||||||
|
"c s" '("Symbols" . consult-eglot-symbols))
|
||||||
|
)
|
||||||
|
|
||||||
|
(defvar-local nemo/lsp-format-on-save t)
|
||||||
|
(defvar nemo/lsp-format-on-save-function #'eglot-format)
|
||||||
|
|
||||||
|
(define-minor-mode nemo/lsp-format-on-save-mode
|
||||||
|
"Run lsp-format-buffer on save."
|
||||||
|
:lighter " fmt"
|
||||||
|
(if nemo/lsp-format-on-save-mode
|
||||||
|
(add-hook 'before-save-hook nemo/lsp-format-on-save-function nil t)
|
||||||
|
(remove-hook 'before-save-hook nemo/lsp-format-on-save-function nil t)
|
||||||
|
))
|
||||||
|
|
||||||
|
(defun nemo/do-lsp-format-on-save ()
|
||||||
|
"Format on save using LSP server."
|
||||||
|
(if nemo/lsp-format-on-save
|
||||||
|
(nemo/lsp-format-on-save-function)))
|
||||||
|
#+end_src
|
||||||
|
** COMMENT LSP
|
||||||
Use lsp-mode and lsp-ui for LSP functionality.
|
Use lsp-mode and lsp-ui for LSP functionality.
|
||||||
Emacs has its own internal LSP client called eglot, but I've never used it and I'm relatively happy with lsp-mode.
|
Emacs has its own internal LSP client called eglot, but I've never used it and I'm relatively happy with lsp-mode.
|
||||||
LSP sets it's prefix key to =s-l= by default, which uses the Super key which I use as my Mod key in sway, so I can't use it in emacs.
|
LSP sets it's prefix key to =s-l= by default, which uses the Super key which I use as my Mod key in sway, so I can't use it in emacs.
|
||||||
|
@ -1615,7 +1701,7 @@ LSP sets it's prefix key to =s-l= by default, which uses the Super key which I u
|
||||||
:hook (lsp-mode . lsp-inlay-hints-mode)
|
:hook (lsp-mode . lsp-inlay-hints-mode)
|
||||||
:init
|
:init
|
||||||
(setq lsp-keymap-prefix "C-l")
|
(setq lsp-keymap-prefix "C-l")
|
||||||
(add-to-list 'completion-at-point-functions #'lsp-completion-at-point)
|
;; (add-to-list 'completion-at-point-functions #'lsp-completion-at-point)
|
||||||
;; (advice-add 'lsp :before #'envrc-reload)
|
;; (advice-add 'lsp :before #'envrc-reload)
|
||||||
:commands lsp
|
:commands lsp
|
||||||
:general-config
|
:general-config
|
||||||
|
@ -2046,7 +2132,7 @@ delimiters < and >'s."
|
||||||
:defer t
|
:defer t
|
||||||
:after (inheritenv envrc)
|
:after (inheritenv envrc)
|
||||||
;; :after (rust-mode)
|
;; :after (rust-mode)
|
||||||
:hook(rustic-mode . nemo/lsp-format-on-save-mode)
|
;; :hook(rustic-mode . nemo/lsp-format-on-save-mode)
|
||||||
:general-config
|
:general-config
|
||||||
(general-define-key
|
(general-define-key
|
||||||
:prefix-map 'nemo/rust-map
|
:prefix-map 'nemo/rust-map
|
||||||
|
@ -2078,7 +2164,6 @@ delimiters < and >'s."
|
||||||
;; rustic-format-on-save-method #'rustic-format-buffer
|
;; rustic-format-on-save-method #'rustic-format-buffer
|
||||||
;; rustic-analyzer-command '("/usr/bin/rust-analyzer")
|
;; rustic-analyzer-command '("/usr/bin/rust-analyzer")
|
||||||
)
|
)
|
||||||
;; (setq nemo/lsp-format-on-save t)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -2093,7 +2178,6 @@ delimiters < and >'s."
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package dap-mode
|
(use-package dap-mode
|
||||||
:straight t
|
:straight t
|
||||||
:after (lsp-mode)
|
|
||||||
:config
|
:config
|
||||||
;; (require 'dap-cpptools)
|
;; (require 'dap-cpptools)
|
||||||
;; (dap-cpptools-setup)
|
;; (dap-cpptools-setup)
|
||||||
|
@ -2160,9 +2244,10 @@ Use =zls= automatically with lsp, and =zig-mode=:
|
||||||
:straight t
|
:straight t
|
||||||
:config
|
:config
|
||||||
(add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-mode))
|
(add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-mode))
|
||||||
(setq lsp-zig-enable-build-on-save t
|
;; (setq lsp-zig-enable-build-on-save t
|
||||||
lsp-zig-enable-inlay-hints nil
|
;; lsp-zig-enable-inlay-hints nil
|
||||||
lsp-zig-build-on-save-step "check"))
|
;; lsp-zig-build-on-save-step "check"))
|
||||||
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Nix
|
** Nix
|
||||||
|
|
Loading…
Reference in a new issue