From d2db2799c625d163bbe54500854fc73ec350e574 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 May 2024 20:01:41 +0200 Subject: emacs: make j jump to {lsp,eglot} symbol intelligently --- user/emacs/init.el | 12 +++++++++++- user/settings/emacs.nix | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'user') diff --git a/user/emacs/init.el b/user/emacs/init.el index c72b3082..03f42eda 100644 --- a/user/emacs/init.el +++ b/user/emacs/init.el @@ -1045,6 +1045,10 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve (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 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve (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 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve "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) diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix index 74d42414..54ebf7a2 100644 --- a/user/settings/emacs.nix +++ b/user/settings/emacs.nix @@ -81,6 +81,7 @@ in consult-dir consult-ghq consult-eglot + consult-lsp crux dired-git-info docker-compose-mode -- cgit 1.4.1