From bd1399105026c7b067dc197b31ccdb2602700a86 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Sat, 30 Oct 2021 12:09:54 -0500 Subject: 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 --- queries/rust/highlights.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'queries/rust') 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 -- cgit v1.2.3-70-g09d2