mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
feat(navigation/imenu): improve C-t imenu keybinding
Use consult-lsp-file-symbols if available and lsp-mode is enabled in current buffer. Otherwise fall back to consult-imenu. Also fall back on consult-lsp-file-symbols if it produces an error, which seems to happen for some language servers right now.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
(use-package consult
|
||||
:defer t
|
||||
:bind
|
||||
("C-t" . consult-imenu)
|
||||
("C-t" . siren-consult-imenu)
|
||||
("C-x b" . consult-buffer)
|
||||
("M-g M-g" . consult-goto-line)
|
||||
|
||||
@@ -22,6 +22,19 @@
|
||||
(consult-project-root-function 'siren-consult-project-root)
|
||||
|
||||
:init
|
||||
(defun siren-consult-imenu ()
|
||||
"Intelligently trigger consult-lsp-file-symbols or consult-imenu."
|
||||
(interactive)
|
||||
(if (and (fboundp 'consult-lsp-file-symbols)
|
||||
(boundp 'lsp-mode)
|
||||
lsp-mode)
|
||||
;; consult-lsp-file-symbols errors on some language servers, in such
|
||||
;; a case, fall back to consult-imenu.
|
||||
(condition-case _
|
||||
(consult-lsp-file-symbols)
|
||||
('error (consult-imenu)))
|
||||
(consult-imenu)))
|
||||
|
||||
(defun siren-consult-project-root (&rest args)
|
||||
"Call projectile-project-root if defined, otherwise return empty string."
|
||||
(if (fboundp 'projectile-project-root)
|
||||
|
||||
Reference in New Issue
Block a user