mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
Rust: highlight uppercase identifiers in match arms as constant (#1940)
* Rust: highlight uppercase identifiers in match arms as constant Closes https://github.com/nvim-treesitter/nvim-treesitter/issues/1928 * Highlight builtins
This commit is contained in:
parent
d53b04189e
commit
bd13991050
1 changed files with 15 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
|||
; Identifier conventions
|
||||
|
||||
(identifier) @variable
|
||||
((identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
(const_item
|
||||
name: (identifier) @constant)
|
||||
; Assume all-caps names are constants
|
||||
|
|
@ -82,6 +84,19 @@
|
|||
name: (identifier) @constant)
|
||||
(#match? @constant "^[A-Z]"))
|
||||
|
||||
; Assume uppercase names in a match arm are constants.
|
||||
((match_arm
|
||||
pattern: (match_pattern (identifier) @constant))
|
||||
(#match? @constant "^[A-Z]"))
|
||||
((match_arm
|
||||
pattern: (match_pattern
|
||||
(scoped_identifier
|
||||
name: (identifier) @constant)))
|
||||
(#match? @constant "^[A-Z]"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
|
||||
|
||||
;; Macro definitions
|
||||
"$" @function.macro
|
||||
(metavariable) @function.macro
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue