summaryrefslogtreecommitdiff
path: root/lisp/progmodes/rust-ts-mode.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2023-02-05 15:46:28 +0200
committerDmitry Gutov <dgutov@yandex.ru>2023-02-05 15:50:16 +0200
commit0c125fcc67a47b933716124223404a45e73357c7 (patch)
treee2ebb0d44dd108f4efbc4b02dc3110c18e95f625 /lisp/progmodes/rust-ts-mode.el
parent1dd751c3ac4e4276b461b83df7d9c4d002cf016e (diff)
downloademacs-0c125fcc67a47b933716124223404a45e73357c7.tar.gz
emacs-0c125fcc67a47b933716124223404a45e73357c7.tar.bz2
emacs-0c125fcc67a47b933716124223404a45e73357c7.zip
Make highlighting more regular across TS modes (bug#61205)
* doc/emacs/display.texi (Parser-based Font Lock): Update description of treesit-font-lock-level, moving 'property' to level 4. * lisp/treesit.el (treesit-font-lock-level): Likewise, in docstring. * lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Do that here. * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode): Add a comment. * lisp/progmodes/go-ts-mode.el (go-ts-mode): Add 'definition' to level 1. Move 'function', 'property' and 'variable' to level 4. (go-ts-mode--font-lock-settings): Move a bunch of existing rules to 'definition'. Add highlighting of function parameters. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode) (rust-ts-mode--font-lock-settings): Same. And also change "scoped identifiers" highlights to only match capitalized names.
Diffstat (limited to 'lisp/progmodes/rust-ts-mode.el')
-rw-r--r--lisp/progmodes/rust-ts-mode.el35
1 files changed, 21 insertions, 14 deletions
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index e317793d211..5722d037bba 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -156,6 +156,16 @@
'((["," "." ";" ":" "::"]) @font-lock-delimiter-face)
:language 'rust
+ :feature 'definition
+ '((function_item name: (identifier) @font-lock-function-name-face)
+ (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)))
+
+ :language 'rust
:feature 'function
'((call_expression
function:
@@ -164,15 +174,12 @@
field: (field_identifier) @font-lock-function-name-face)
(scoped_identifier
name: (identifier) @font-lock-function-name-face)])
- (function_item (identifier) @font-lock-function-name-face)
(generic_function
function: [(identifier) @font-lock-function-name-face
(field_expression
field: (field_identifier) @font-lock-function-name-face)
(scoped_identifier
name: (identifier) @font-lock-function-name-face)])
- (macro_definition "macro_rules!" @font-lock-constant-face)
- (macro_definition (identifier) @font-lock-preprocessor-face)
(macro_invocation macro: (identifier) @font-lock-preprocessor-face))
:language 'rust
@@ -208,20 +215,20 @@
(mod_item name: (identifier) @font-lock-constant-face)
(primitive_type) @font-lock-type-face
(type_identifier) @font-lock-type-face
- (scoped_identifier name: (identifier) @font-lock-type-face)
- (scoped_identifier path: (identifier) @font-lock-constant-face)
- (scoped_identifier
- (scoped_identifier
- path: (identifier) @font-lock-constant-face))
+ ((scoped_identifier name: (identifier) @font-lock-type-face)
+ (:match "^[A-Z]" @font-lock-type-face))
+ ((scoped_identifier path: (identifier) @font-lock-type-face)
+ (:match "^[A-Z]" @font-lock-type-face))
+ ((scoped_identifier
+ (scoped_identifier
+ path: (identifier) @font-lock-type-face))
+ (:match "^[A-Z]" @font-lock-type-face))
((scoped_identifier
path: [(identifier) @font-lock-type-face
(scoped_identifier
name: (identifier) @font-lock-type-face)])
(:match "^[A-Z]" @font-lock-type-face))
(scoped_type_identifier path: (identifier) @font-lock-constant-face)
- (scoped_use_list
- path: [(identifier) @font-lock-constant-face
- (scoped_identifier (identifier) @font-lock-constant-face)])
(type_identifier) @font-lock-type-face
(use_as_clause alias: (identifier) @font-lock-type-face)
(use_list (identifier) @font-lock-type-face))
@@ -317,11 +324,11 @@ delimiters < and >'s."
;; Font-lock.
(setq-local treesit-font-lock-settings rust-ts-mode--font-lock-settings)
(setq-local treesit-font-lock-feature-list
- '(( comment)
+ '(( comment definition)
( keyword string)
( attribute builtin constant escape-sequence
- function number property type variable)
- ( bracket delimiter error operator)))
+ number type)
+ ( bracket delimiter error function operator property variable)))
;; Imenu.
(setq-local treesit-simple-imenu-settings