emacs: make <leader>j jump to {lsp,eglot} symbol intelligently
Alan Pearce alan@alanpearce.eu
Mon, 20 May 2024 20:01:41 +0200
2 files changed, 12 insertions(+), 1 deletions(-)
M user/emacs/init.el → user/emacs/init.el
@@ -1045,6 +1045,10 @@ (defvaralias 'go-ts-mode-hook 'go-mode-hook) (defvaralias 'nix-ts-mode-hook 'nix-mode-hook) +(use-package consult-lsp + :commands (consult-lsp-symbols + consult-lsp-diagnostics)) + (use-package eglot :defer 3 :general (:states 'normal :keymaps 'eglot-mode-map @@ -1142,6 +1146,12 @@ (if lsp-mode (call-interactively #'lsp-rename) (call-interactively #'eglot-rename))) +(defun my/ls-consult-symbol () + (interactive) + (if lsp-mode + (call-interactively #'consult-lsp-symbols) + (call-interactively #'consult-eglot-symbols))) + ;; Inside a javascript project, it's common to install tools locally to ;; the project. This will allows emacs to find their executables. @@ -1199,7 +1209,7 @@ "h" '(:keymap ehelp-map :package ehelp) "w" '(:keymap evil-window-map :package evil) "x" '(:keymap ctl-x-map) "c" (general-simulate-key "C-c") - "j" #'consult-eglot-symbols + "j" #'my/ls-consult-symbol "r" #'my/ls-rename "q" #'evil-delete-buffer "p" '(:keymap project-prefix-map :package project)
M user/settings/emacs.nix → user/settings/emacs.nix
@@ -81,6 +81,7 @@ consult consult-dir consult-ghq consult-eglot + consult-lsp crux dired-git-info docker-compose-mode