From 4c1be88d5e998e53ee33d994b274aa14a4c0ff09 Mon Sep 17 00:00:00 2001 From: Yu-Fu Fu Date: Wed, 23 Oct 2024 23:49:16 -0400 Subject: [PATCH] use find-def/ref fallback when there is no lsp server (like emacs-lisp-mode) Let it fallback when not having lsp servers. For example, in emacs-lisp-mode, we can use GNU global and Citre to find references by setting find-ref-fallback to citre-jump-to-reference. --- lsp-bridge.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lsp-bridge.el b/lsp-bridge.el index 18b2f97466..9b7d73312e 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -1959,7 +1959,9 @@ Off by default." (lsp-bridge--set-mark-ring-in-new-buffer)) (t (setq-local lsp-bridge-jump-to-def-in-other-window nil) - (lsp-bridge-call-file-api "find_define" (lsp-bridge--position))))) + (if (lsp-bridge-has-lsp-server-p) + (lsp-bridge-call-file-api "find_define" (lsp-bridge--position)) + (lsp-bridge-find-def-fallback (lsp-bridge--position)))))) (defun lsp-bridge-find-def-other-window () (interactive) @@ -1970,7 +1972,9 @@ Off by default." (lsp-bridge--set-mark-ring-in-new-buffer)) (t (setq-local lsp-bridge-jump-to-def-in-other-window t) - (lsp-bridge-call-file-api "find_define" (lsp-bridge--position))))) + (if (lsp-bridge-has-lsp-server-p) + (lsp-bridge-call-file-api "find_define" (lsp-bridge--position)) + (lsp-bridge-find-def-fallback (lsp-bridge--position)))))) (defun lsp-bridge-find-def-return () "Pop off lsp-bridge-mark-ring and jump to the top location." @@ -2019,7 +2023,9 @@ Off by default." (defun lsp-bridge-find-references () (interactive) - (lsp-bridge-call-file-api "find_references" (lsp-bridge--position))) + (if (lsp-bridge-has-lsp-server-p) + (lsp-bridge-call-file-api "find_references" (lsp-bridge--position)) + (lsp-bridge-find-ref-fallback (lsp-bridge--position)))) (defun lsp-bridge-find-def-fallback (position) (if (not (= (length lsp-bridge-peek-ace-list) 0))