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 | |
| parent | Add fennel ftdetect file (#1952) (diff) | |
| download | nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.tar nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.tar.gz nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.tar.bz2 nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.tar.lz nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.tar.xz nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.tar.zst nvim-treesitter-bd1399105026c7b067dc197b31ccdb2602700a86.zip | |
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
| -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 87c65dffa..af8e6e5aa 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 |
