Skip to content

Commit

Permalink
Add acm-backend-elisp-find-def, and add it in lsp-bridge-find-def
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Jul 9, 2023
1 parent 56334a3 commit 9d62ea2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
20 changes: 20 additions & 0 deletions acm/acm-backend-elisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@
(t
"variable")))

(defun acm-backend-elisp-open-feature-file (feature-string)
"Open the file that defines the given FEATURE-STRING."
(let ((library-path (locate-library feature-string)))
(if library-path
(find-file library-path)
(message "Feature not found: %s" feature-string))))

(defun acm-backend-elisp-find-def ()
(let* ((symbol-string (thing-at-point 'symbol t))
(symbol (intern symbol-string)))
(pcase (acm-backend-elisp-symbol-type symbol)
("feature" (acm-backend-elisp-open-feature-file symbol-string))
("special form" (find-variable symbol))
("function" (find-function symbol))
("macro" (find-function symbol))
("face" (find-face-definition symbol))
("custom" (find-variable symbol))
("constant" (find-variable symbol))
("variable" (find-variable symbol)))))

(defun acm-backend-elisp-global-symbols ()
(all-completions ""
obarray
Expand Down
16 changes: 12 additions & 4 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -1471,13 +1471,21 @@ So we build this macro to restore postion after code format."

(defun lsp-bridge-find-def ()
(interactive)
(setq-local lsp-bridge-jump-to-def-in-other-window nil)
(lsp-bridge-call-file-api "find_define" (lsp-bridge--position)))
(cond
((acm-is-elisp-mode-p)
(acm-backend-elisp-find-def))
(t
(setq-local lsp-bridge-jump-to-def-in-other-window nil)
(lsp-bridge-call-file-api "find_define" (lsp-bridge--position)))))

(defun lsp-bridge-find-def-other-window ()
(interactive)
(setq-local lsp-bridge-jump-to-def-in-other-window t)
(lsp-bridge-call-file-api "find_define" (lsp-bridge--position)))
(cond
((acm-is-elisp-mode-p)
(acm-backend-elisp-find-def))
(t
(setq-local lsp-bridge-jump-to-def-in-other-window t)
(lsp-bridge-call-file-api "find_define" (lsp-bridge--position)))))

(defun lsp-bridge-find-def-return ()
"Pop off lsp-bridge-mark-ring and jump to the top location."
Expand Down

0 comments on commit 9d62ea2

Please sign in to comment.