Highlight more complex function parameters
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--fontify-parameter): New function. (rust-ts-mode--font-lock-settings): Use it.
This commit is contained in:
parent
58dc03ba7e
commit
3ffd0eddce
1 changed files with 13 additions and 3 deletions
|
@ -161,9 +161,7 @@
|
|||
(macro_definition "macro_rules!" @font-lock-constant-face)
|
||||
(macro_definition (identifier) @font-lock-preprocessor-face)
|
||||
(field_declaration name: (field_identifier) @font-lock-property-face)
|
||||
(parameter pattern: (identifier) @font-lock-variable-name-face)
|
||||
(parameter
|
||||
pattern: (reference_pattern (identifier) @font-lock-variable-name-face)))
|
||||
(parameter) @rust-ts-mode--fontify-parameter)
|
||||
|
||||
:language 'rust
|
||||
:feature 'function
|
||||
|
@ -256,6 +254,18 @@
|
|||
'((ERROR) @font-lock-warning-face))
|
||||
"Tree-sitter font-lock settings for `rust-ts-mode'.")
|
||||
|
||||
(defalias 'rust-ts-mode--fontify-parameter
|
||||
(and
|
||||
(treesit-available-p)
|
||||
`(lambda (node override start end &rest _)
|
||||
(let ((captures (treesit-query-capture
|
||||
(treesit-node-child-by-field-name node "pattern")
|
||||
,(treesit-query-compile 'rust '((identifier) @id)))))
|
||||
(pcase-dolist (`(_name . ,id) captures)
|
||||
(treesit-fontify-with-override
|
||||
(treesit-node-start id) (treesit-node-end id)
|
||||
'font-lock-variable-name-face override start end))))))
|
||||
|
||||
(defun rust-ts-mode--defun-name (node)
|
||||
"Return the defun name of NODE.
|
||||
Return nil if there is no name or if NODE is not a defun node."
|
||||
|
|
Loading…
Add table
Reference in a new issue