diff options
| author | Santos Gallegos <stsewd@protonmail.com> | 2021-10-30 12:09:54 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-30 12:09:54 -0500 |
| commit | bd1399105026c7b067dc197b31ccdb2602700a86 (patch) | |
| tree | 73fe0492becf920fc19f8ac44ebbc0679865c64b /queries/rust | |
| parent | d53b04189e9ec2996c3fe205652f864e963778a3 (diff) | |
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
Diffstat (limited to 'queries/rust')
| -rw-r--r-- | queries/rust/highlights.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index 87c65dff..af8e6e5a 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -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 |
