diff options
-rw-r--r-- | TODO.md | 5 | ||||
-rw-r--r-- | runtime/queries/rust/highlights.scm | 92 | ||||
-rw-r--r-- | theme.toml | 3 |
3 files changed, 84 insertions, 16 deletions
@@ -1,5 +1,4 @@ - Refactor tree-sitter-highlight to work like the atom one, recomputing partial tree updates. -- syntax errors highlight query ------ @@ -19,15 +18,11 @@ - [ ] document.on_type provider triggers - [ ] completion isIncomplete support -- [ ] extract indentation calculation queries so we can support other languages. - 1 -- [ ] :format/:fmt that formats the buffer - [ ] respect view fullscreen flag - [ ] Implement marks (superset of Selection/Range) - [ ] nixos packaging -- [ ] CI binary builds - [ ] = for auto indent line/selection - [ ] :x for closing buffers diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 7a275d8e..88ffcc27 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -1,10 +1,28 @@ ; Identifier conventions + ; Assume all-caps names are constants ((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]+$'")) +; Assume other uppercase names are enum constructors +((identifier) @constructor + (#match? @constructor "^[A-Z]")) + ; Assume that uppercase names in paths are types +(mod_item + name: (identifier) @namespace) +(scoped_identifier + path: (identifier) @namespace) +(scoped_identifier + (scoped_identifier + name: (identifier) @namespace)) +(scoped_type_identifier + path: (identifier) @namespace) +(scoped_type_identifier + (scoped_identifier + name: (identifier) @namespace)) + ((scoped_identifier path: (identifier) @type) (#match? @type "^[A-Z]")) @@ -13,9 +31,15 @@ name: (identifier) @type)) (#match? @type "^[A-Z]")) -; Assume other uppercase names are enum constructors -((identifier) @constructor - (#match? @constructor "^[A-Z]")) +; Namespaces + +(crate) @namespace +(scoped_use_list + path: (identifier) @namespace) +(scoped_use_list + path: (scoped_identifier + (identifier) @namespace)) +(use_list (scoped_identifier (identifier) @namespace . (_))) ; Function calls @@ -38,9 +62,19 @@ function: (field_expression field: (field_identifier) @function.method)) +; (macro_invocation +; macro: (identifier) @function.macro +; "!" @function.macro) +(macro_invocation + macro: (identifier) @function.macro) (macro_invocation - macro: (identifier) @function.macro - "!" @function.macro) + macro: (scoped_identifier + (identifier) @function.macro .)) + +; (metavariable) @variable +(metavariable) @function.macro + +"$" @function.macro ; Function definitions @@ -73,6 +107,7 @@ ";" @punctuation.delimiter (parameter (identifier) @variable.parameter) +(closure_parameters (_) @variable.parameter) (lifetime (identifier) @label) @@ -114,9 +149,9 @@ (scoped_use_list (self) @keyword) (scoped_identifier (self) @keyword) (super) @keyword +"as" @keyword (self) @variable.builtin -(metavariable) @variable [ (char_literal) @@ -133,7 +168,44 @@ (attribute_item) @attribute (inner_attribute_item) @attribute -"as" @operator -"*" @operator -"&" @operator -"'" @operator +[ +"*" +"'" +"->" +"=>" +"<=" +"=" +"==" +"!" +"!=" +"%" +"%=" +"&" +"&=" +"&&" +"|" +"|=" +"||" +"^" +"^=" +"*" +"*=" +"-" +"-=" +"+" +"+=" +"/" +"/=" +">" +"<" +">=" +">>" +"<<" +">>=" +"@" +".." +"..=" +"'" +] @operator + +"?" @special @@ -1,9 +1,11 @@ "attribute" = "#dbbfef" # lilac "keyword" = "#eccdba" # almond "keyword.directive" = "#dbbfef" # lilac -- preprocessor comments (#if in C) +"namespace" = "#dbbfef" # lilac "punctuation" = "#a4a0e8" # lavender "punctuation.delimiter" = "#a4a0e8" # lavender "operator" = "#dbbfef" # lilac +"special" = "#efba5d" # honey # "property" = "#a4a0e8" # lavender "property" = "#ffffff" # white "variable" = "#a4a0e8" # lavender @@ -31,7 +33,6 @@ # TODO: variable as lilac # TODO: mod/use statements as white # TODO: mod stuff as chamois -# TODO: add "(scoped_identifier) @path" for std::mem:: # # concat (ERROR) @syntax-error and "MISSING ;" selectors for errors |