This commit is contained in:
2026-08-25 01:16:44 -07:00
parent fce9247c63
commit 2dcbc82889
2 changed files with 146 additions and 131 deletions
+23 -23
View File
@@ -143,24 +143,24 @@ command.")
;; reserved words
(command_name
((word) @font-lock-keyword-face
(:match ,(rx-to-string
`(seq bos
(or ,@(zsh-ts-mode--other-keywords))
eos))
@font-lock-keyword-face))))
(:match? ,(rx-to-string
`(seq bos
(or ,@(zsh-ts-mode--other-keywords))
eos))
@font-lock-keyword-face))))
:feature 'command
:language 'zsh
`(;; builtin commands
(command_name
((word) @font-lock-builtin-face
(:match ,(let ((builtins
(sh-feature sh-builtins)))
(rx-to-string
`(seq bos
(or ,@builtins)
eos)))
@font-lock-builtin-face)))
(:match? ,(let ((builtins
(sh-feature sh-builtins)))
(rx-to-string
`(seq bos
(or ,@builtins)
eos)))
@font-lock-builtin-face)))
;; function/non-builtin command calls
(command_name (word) @font-lock-function-name-face))
@@ -182,8 +182,8 @@ command.")
:override 'prepend
`((declaration_command
argument: ((_) @font-lock-variable-name-face
(:match ,(rx-to-string '(seq bos (not "-")))
@font-lock-variable-name-face))))
(:match? ,(rx-to-string '(seq bos (not "-")))
@font-lock-variable-name-face))))
;; let variable declarations (handled differently by the parser)
@@ -192,10 +192,10 @@ command.")
:override 'prepend
`((command
(command_name ((word) @ignore
(:equal "let" @ignore)))
(:eq? "let" @ignore)))
argument: ((_) @zsh-ts-mode--fontify-let-arg
(:match ,(rx-to-string '(seq bos (not "-")))
@zsh-ts-mode--fontify-let-arg))))
(:match? ,(rx-to-string '(seq bos (not "-")))
@zsh-ts-mode--fontify-let-arg))))
:feature 'for-variable
:language 'zsh
@@ -213,7 +213,7 @@ command.")
:feature 'number
:language 'zsh
`(((word) @font-lock-number-face
(:match "\\`[0-9]+\\'" @font-lock-number-face))
(:match? "\\`[0-9]+\\'" @font-lock-number-face))
((number) @font-lock-number-face))
:feature 'bracket
@@ -287,7 +287,7 @@ Return non-nil if NODE is not an anonymous function."
@var))
((variable_name) @var)
((word) @func
(:pred zsh-ts-mode--not-let-predicate @func))))
(:pred? zsh-ts-mode--not-let-predicate @func))))
"Query for `zsh-ts-mode' `xref-backend-identifier-at-point'.")
(cl-defun zsh-ts-mode--extract-variable-from-face-at (&optional (pos (point)))
@@ -381,10 +381,10 @@ Return non-nil if NODE is not an anonymous function."
(binary_expression left: (variable_name) @non-let
operator: "=")
(command name: ((command_name) @let.name
(:equal @let.name "let"))
(:eq? @let.name "let"))
argument: ((word) @let-arg
(:match ,(rx-to-string '(seq bos (not "-")))
@let-arg)))))
(:match? ,(rx-to-string '(seq bos (not "-")))
@let-arg)))))
"Variable query for `zsh-ts-mode--xref-variable-definitions'.")
(defun zsh-ts-mode--xref-variable-definitions (identifier)
@@ -490,7 +490,7 @@ Return non-nil if NODE is not an anonymous function."
'zsh '(((simple_variable_name) @ident)
((special_variable_name) @ident)
((variable_name) @ident)
(command name: (command_name ((word) @cname (:equal @cname "let")))
(command name: (command_name ((word) @cname (:eq? @cname "let")))
argument: (word) @ident)
(declaration_command argument: (word) @ident)
(command name: (command_name (word) @ident))