aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2023-02-05 16:43:59 +0200
committerDmitry Gutov2023-02-05 16:44:32 +0200
commit3ffd0eddce651aabefedf10249ebd9d6e7b5b8fa (patch)
treeccd14e3d1e47eca1ee39b0e992d8b2466b5d9d41
parent58dc03ba7e4c67027f49ed9f741ceb68de262f72 (diff)
downloademacs-3ffd0eddce651aabefedf10249ebd9d6e7b5b8fa.tar.gz
emacs-3ffd0eddce651aabefedf10249ebd9d6e7b5b8fa.zip
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.
-rw-r--r--lisp/progmodes/rust-ts-mode.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 5722d037bba..e46fa0342dd 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -161,9 +161,7 @@
161 (macro_definition "macro_rules!" @font-lock-constant-face) 161 (macro_definition "macro_rules!" @font-lock-constant-face)
162 (macro_definition (identifier) @font-lock-preprocessor-face) 162 (macro_definition (identifier) @font-lock-preprocessor-face)
163 (field_declaration name: (field_identifier) @font-lock-property-face) 163 (field_declaration name: (field_identifier) @font-lock-property-face)
164 (parameter pattern: (identifier) @font-lock-variable-name-face) 164 (parameter) @rust-ts-mode--fontify-parameter)
165 (parameter
166 pattern: (reference_pattern (identifier) @font-lock-variable-name-face)))
167 165
168 :language 'rust 166 :language 'rust
169 :feature 'function 167 :feature 'function
@@ -256,6 +254,18 @@
256 '((ERROR) @font-lock-warning-face)) 254 '((ERROR) @font-lock-warning-face))
257 "Tree-sitter font-lock settings for `rust-ts-mode'.") 255 "Tree-sitter font-lock settings for `rust-ts-mode'.")
258 256
257(defalias 'rust-ts-mode--fontify-parameter
258 (and
259 (treesit-available-p)
260 `(lambda (node override start end &rest _)
261 (let ((captures (treesit-query-capture
262 (treesit-node-child-by-field-name node "pattern")
263 ,(treesit-query-compile 'rust '((identifier) @id)))))
264 (pcase-dolist (`(_name . ,id) captures)
265 (treesit-fontify-with-override
266 (treesit-node-start id) (treesit-node-end id)
267 'font-lock-variable-name-face override start end))))))
268
259(defun rust-ts-mode--defun-name (node) 269(defun rust-ts-mode--defun-name (node)
260 "Return the defun name of NODE. 270 "Return the defun name of NODE.
261Return nil if there is no name or if NODE is not a defun node." 271Return nil if there is no name or if NODE is not a defun node."