|
| 1 | +; Punctuation |
| 2 | +[ |
| 3 | + "(" |
| 4 | + ")" |
| 5 | + "[" |
| 6 | + "]" |
| 7 | + "{" |
| 8 | + "}" |
| 9 | + "<<" |
| 10 | + ">>" |
| 11 | +] @punctuation.bracket |
| 12 | +[ |
| 13 | + "." |
| 14 | + "," |
| 15 | + ;; Controversial -- maybe some are operators? |
| 16 | + ":" |
| 17 | + "#" |
| 18 | + "=" |
| 19 | + "->" |
| 20 | + ".." |
| 21 | + "-" |
| 22 | + "<-" |
| 23 | +] @punctuation.delimiter |
| 24 | + |
| 25 | +; Variables |
| 26 | +(identifier) @variable |
| 27 | +(discard) @comment.unused |
| 28 | + |
1 | 29 | ; Comments |
2 | 30 | (module_comment) @comment |
3 | 31 | (statement_comment) @comment |
|
7 | 35 | (constant |
8 | 36 | name: (identifier) @constant) |
9 | 37 |
|
| 38 | +; "Properties" |
| 39 | +; Assumed to be intended to refer to a name for a field; something that comes |
| 40 | +; before ":" or after "." |
| 41 | +; e.g. record field names, tuple indices, names for named arguments, etc |
| 42 | +(label) @property |
| 43 | +(tuple_access |
| 44 | + index: (integer) @property) |
| 45 | + |
10 | 46 | ; Modules |
11 | 47 | (module) @module |
12 | 48 | (import alias: (identifier) @module) |
13 | 49 | (remote_type_identifier |
14 | 50 | module: (identifier) @module) |
15 | 51 | (remote_constructor_name |
16 | 52 | module: (identifier) @module) |
17 | | -((field_access |
18 | | - record: (identifier) @module |
19 | | - field: (label) @function) |
20 | | - (#is-not? local)) |
21 | 53 |
|
22 | 54 | ; Functions |
23 | 55 | (unqualified_import (identifier) @function) |
|
37 | 69 | right: (identifier) @function) |
38 | 70 | (#is-not? local)) |
39 | 71 |
|
40 | | -; "Properties" |
41 | | -; Assumed to be intended to refer to a name for a field; something that comes |
42 | | -; before ":" or after "." |
43 | | -; e.g. record field names, tuple indices, names for named arguments, etc |
44 | | -(label) @property |
45 | | -(tuple_access |
46 | | - index: (integer) @property) |
| 72 | +; TODO: `#is-not? local` applies to entire patterns but ideally it would accept |
| 73 | +; a capture to check as a local. This needs to be suggested upstream. Until this |
| 74 | +; is a part of the CLI's highlighter we can't distinguish between function calls |
| 75 | +; on modules and accesses of record fields. |
| 76 | +(function_call function: (field_access field: (label) @function)) ; Ideally this pattern would be removed, |
| 77 | +((field_access |
| 78 | + record: (identifier) @module) |
| 79 | + ; field: (label) @function) ; this line would be uncommented, |
| 80 | + (#is-not? local)) ; and this line would be `(#is-not? local @module)`. |
47 | 81 |
|
48 | 82 | ; Attributes |
49 | 83 | (attribute |
|
61 | 95 |
|
62 | 96 | ; Literals |
63 | 97 | (string) @string |
| 98 | +(escape_sequence) @string.escape |
64 | 99 | ((escape_sequence) @warning |
65 | 100 | ; Deprecated in v0.33.0-rc2: |
66 | 101 | (#eq? @warning "\\e")) |
67 | | -(escape_sequence) @string.escape |
68 | 102 | (bit_string_segment_option) @function.builtin |
69 | 103 | (integer) @number |
70 | 104 | (float) @number |
|
73 | 107 | ; TODO: when tree-sitter supports `#any-of?` in the Rust bindings, |
74 | 108 | ; refactor this to use `#any-of?` rather than `#match?` |
75 | 109 | ((identifier) @error |
76 | | - (#match? @error "^(auto|delegate|derive|else|implement|macro|test)$")) |
77 | | - |
78 | | -; Variables |
79 | | -(identifier) @variable |
80 | | -(discard) @comment.unused |
| 110 | + (#any-of? @error "auto" "delegate" "derive" "else" "implement" "macro" "test")) |
81 | 111 |
|
82 | 112 | ; Keywords |
83 | 113 | [ |
|
105 | 135 | operator: _ @operator) |
106 | 136 | (boolean_negation "!" @operator) |
107 | 137 | (integer_negation "-" @operator) |
108 | | - |
109 | | -; Punctuation |
110 | | -[ |
111 | | - "(" |
112 | | - ")" |
113 | | - "[" |
114 | | - "]" |
115 | | - "{" |
116 | | - "}" |
117 | | - "<<" |
118 | | - ">>" |
119 | | -] @punctuation.bracket |
120 | | -[ |
121 | | - "." |
122 | | - "," |
123 | | - ;; Controversial -- maybe some are operators? |
124 | | - ":" |
125 | | - "#" |
126 | | - "=" |
127 | | - "->" |
128 | | - ".." |
129 | | - "-" |
130 | | - "<-" |
131 | | -] @punctuation.delimiter |
|
0 commit comments