|
| 1 | + (identifier) @variable |
| 2 | + |
| 3 | +(operator) @operator |
| 4 | +(range_expression ":" @operator) |
| 5 | +(pair_expression "=>" @operator) |
| 6 | + |
| 7 | +;; In case you want type highlighting based on Julia naming conventions (this might collide with mathematical notation) |
| 8 | +;((identifier) @type ; exception: mark `A_foo` sort of identifiers as variables |
| 9 | + ;(match? @type "^[A-Z][^_]")) |
| 10 | +((identifier) @constant |
| 11 | + (#match? @constant "^[A-Z][A-Z_]{2}[A-Z_]*$")) |
| 12 | + |
| 13 | +(macro_identifier) @function.macro |
| 14 | +(macro_identifier (identifier) @function.macro) ; for any one using the variable highlight |
| 15 | +(macro_definition |
| 16 | + name: (identifier) @function.macro |
| 17 | + ["macro" "end" @keyword]) |
| 18 | + |
| 19 | +(field_expression |
| 20 | + (identifier) |
| 21 | + (identifier) @field .) |
| 22 | + |
| 23 | +(function_definition |
| 24 | + name: (identifier) @function) |
| 25 | +(call_expression |
| 26 | + (identifier) @function) |
| 27 | +(call_expression |
| 28 | + (field_expression (identifier) @method .)) |
| 29 | +(broadcast_call_expression |
| 30 | + (identifier) @function) |
| 31 | +(broadcast_call_expression |
| 32 | + (field_expression (identifier) @method .)) |
| 33 | +(parameter_list |
| 34 | + (identifier) @parameter) |
| 35 | +(parameter_list |
| 36 | + (optional_parameter . |
| 37 | + (identifier) @parameter)) |
| 38 | +(typed_parameter |
| 39 | + (identifier) @parameter |
| 40 | + (identifier) @type) |
| 41 | +(type_parameter_list |
| 42 | + (identifier) @type) |
| 43 | +(typed_parameter |
| 44 | + (identifier) @parameter |
| 45 | + (parameterized_identifier) @type) |
| 46 | +(function_expression |
| 47 | + . (identifier) @parameter) |
| 48 | +(spread_parameter) @parameter |
| 49 | +(spread_parameter |
| 50 | + (identifier) @parameter) |
| 51 | +(named_argument |
| 52 | + . (identifier) @parameter) |
| 53 | +(argument_list |
| 54 | + (typed_expression |
| 55 | + (identifier) @parameter |
| 56 | + (identifier) @type)) |
| 57 | +(argument_list |
| 58 | + (typed_expression |
| 59 | + (identifier) @parameter |
| 60 | + (parameterized_identifier) @type)) |
| 61 | + |
| 62 | +;; Symbol expressions (:my-wanna-be-lisp-keyword) |
| 63 | +(quote_expression |
| 64 | + (identifier)) @symbol |
| 65 | + |
| 66 | +;; Parsing error! foo (::Type) gets parsed as two quote expressions |
| 67 | +(argument_list |
| 68 | + (quote_expression |
| 69 | + (quote_expression |
| 70 | + (identifier) @type))) |
| 71 | + |
| 72 | +(type_argument_list |
| 73 | + (identifier) @type) |
| 74 | +(parameterized_identifier (_)) @type |
| 75 | +(argument_list |
| 76 | + (typed_expression . (identifier) @parameter)) |
| 77 | + |
| 78 | +(typed_expression |
| 79 | + (identifier) @type .) |
| 80 | +(typed_expression |
| 81 | + (parameterized_identifier) @type .) |
| 82 | + |
| 83 | +(abstract_definition |
| 84 | + name: (identifier) @type) |
| 85 | +(struct_definition |
| 86 | + name: (identifier) @type) |
| 87 | + |
| 88 | +(subscript_expression |
| 89 | + (_) |
| 90 | + (range_expression |
| 91 | + (identifier) @constant.builtin .) |
| 92 | + (#eq? @constant.builtin "end")) |
| 93 | + |
| 94 | +"end" @keyword |
| 95 | + |
| 96 | +(if_statement |
| 97 | + ["if" "end"] @conditional) |
| 98 | +(elseif_clause |
| 99 | + ["elseif"] @conditional) |
| 100 | +(else_clause |
| 101 | + ["else"] @conditional) |
| 102 | +(ternary_expression |
| 103 | + ["?" ":"] @conditional) |
| 104 | + |
| 105 | +(function_definition ["function" "end"] @keyword.function) |
| 106 | + |
| 107 | +[ |
| 108 | + "abstract" |
| 109 | + "const" |
| 110 | + "macro" |
| 111 | + "primitive" |
| 112 | + "struct" |
| 113 | + "type" |
| 114 | +] @keyword |
| 115 | + |
| 116 | +"return" @keyword.return |
| 117 | + |
| 118 | +((identifier) @keyword (#any-of? @keyword "global" "local")) |
| 119 | + |
| 120 | +(compound_expression |
| 121 | + ["begin" "end"] @keyword) |
| 122 | +(try_statement |
| 123 | + ["try" "end" ] @exception) |
| 124 | +(finally_clause |
| 125 | + "finally" @exception) |
| 126 | +(catch_clause |
| 127 | + "catch" @exception) |
| 128 | +(quote_statement |
| 129 | + ["quote" "end"] @keyword) |
| 130 | +(let_statement |
| 131 | + ["let" "end"] @keyword) |
| 132 | +(for_statement |
| 133 | + ["for" "end"] @repeat) |
| 134 | +(while_statement |
| 135 | + ["while" "end"] @repeat) |
| 136 | +(break_statement) @repeat |
| 137 | +(continue_statement) @repeat |
| 138 | +(for_clause |
| 139 | + "for" @repeat) |
| 140 | +(do_clause |
| 141 | + ["do" "end"] @keyword) |
| 142 | + |
| 143 | +"in" @keyword.operator |
| 144 | + |
| 145 | +(export_statement |
| 146 | + ["export"] @include) |
| 147 | + |
| 148 | +(import_statement |
| 149 | + ["import" "using"] @include) |
| 150 | + |
| 151 | +(module_definition |
| 152 | + ["module" "end"] @include) |
| 153 | + |
| 154 | +((identifier) @include (#eq? @include "baremodule")) |
| 155 | + |
| 156 | + |
| 157 | +;;; Literals |
| 158 | + |
| 159 | +(integer_literal) @number |
| 160 | +(float_literal) @float |
| 161 | + |
| 162 | +((identifier) @float |
| 163 | + (#any-of? @float "NaN" "NaN16" "NaN32" |
| 164 | + "Inf" "Inf16" "Inf32")) |
| 165 | + |
| 166 | +((identifier) @boolean |
| 167 | + (#any-of? @boolean "true" "false")) |
| 168 | + |
| 169 | +((identifier) @constant.builtin |
| 170 | + (#any-of? @constant.builtin "nothing" "missing")) |
| 171 | + |
| 172 | +(character_literal) @character |
| 173 | +(escape_sequence) @string.escape |
| 174 | + |
| 175 | +(string_literal) @string |
| 176 | +(prefixed_string_literal |
| 177 | + prefix: (identifier) @function.macro) @string |
| 178 | + |
| 179 | +(command_literal) @string |
| 180 | +(prefixed_command_literal |
| 181 | + prefix: (identifier) @function.macro) @string |
| 182 | + |
| 183 | +[ |
| 184 | + (line_comment) |
| 185 | + (block_comment) |
| 186 | +] @comment |
| 187 | + |
| 188 | +;;; Punctuation |
| 189 | + |
| 190 | +(quote_expression ":" @symbol) |
| 191 | +["::" "." "," "..."] @punctuation.delimiter |
| 192 | +["[" "]" "(" ")" "{" "}"] @punctuation.bracket |
| 193 | + |
| 194 | +(ERROR) @error |
0 commit comments