summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2024-05-20 20:01:41 +0200
committerAlan Pearce2024-05-20 20:01:41 +0200
commitd2db2799c625d163bbe54500854fc73ec350e574 (patch)
tree42554496ef3d678058a386486ef4367364947028 /user
parent0abb318c351a8bdb6cac8998d737bd81340cb0c0 (diff)
downloadnixfiles-d2db2799c625d163bbe54500854fc73ec350e574.tar.lz
nixfiles-d2db2799c625d163bbe54500854fc73ec350e574.tar.zst
nixfiles-d2db2799c625d163bbe54500854fc73ec350e574.zip
emacs: make <leader>j jump to {lsp,eglot} symbol intelligently
Diffstat (limited to 'user')
-rw-r--r--user/emacs/init.el12
-rw-r--r--user/settings/emacs.nix1
2 files changed, 12 insertions, 1 deletions
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