Update zsh-ts-mode.el
This commit is contained in:
@@ -406,6 +406,33 @@ NODE is the argument to let (possibly with a = in it)."
|
||||
(function (zsh-ts-mode--xref-function-definitions identifier))
|
||||
(variable (zsh-ts-mode--xref-variable-definitions identifier))))
|
||||
|
||||
(defun zsh-ts-mode--xref-function-references (identifier)
|
||||
"Find all references for the function IDENTIFIER in the current buffer."
|
||||
(let ((nodes (treesit-query-capture
|
||||
(treesit-buffer-root-node)
|
||||
`((command name: (command_name (word) @name)))
|
||||
nil nil t))
|
||||
(ident-copy (copy-sequence identifier)))
|
||||
(set-text-properties 0 (length ident-copy) nil ident-copy)
|
||||
(cl-loop for node in nodes
|
||||
collect (xref-make
|
||||
(propertize ident-copy 'face
|
||||
'font-lock-function-name-face)
|
||||
(zsh-ts-mode--treesit-node-location node)))))
|
||||
|
||||
(defun zsh-ts-mode--xref-variable-references (identifier)
|
||||
"Find all references for the variable IDENTIFIER in the current buffer."
|
||||
())
|
||||
|
||||
(cl-defmethod xref-backend-references ((_backend (eql zsh-ts)) identifier)
|
||||
"`zsh-ts-mode' implementation for finding xref references for IDENTIFIER."
|
||||
(append
|
||||
;; definitions are references
|
||||
(xref-backend-definitions 'zsh-ts identifier)
|
||||
(cl-case (get-text-property 0 'type identifier)
|
||||
(function (zsh-ts-mode--xref-function-references identifier))
|
||||
(variable (zsh-ts-mode--xref-variable-references identifier)))))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode zsh-ts-mode sh-base-mode "Zsh"
|
||||
;; This function is based mostly on `bash-ts-mode'.
|
||||
|
||||
Reference in New Issue
Block a user