|
| 1 | +; Modules |
| 2 | +;-------- |
| 3 | + |
| 4 | +[(module_name) (module_type_name)] @module |
| 5 | + |
| 6 | +; Types |
| 7 | +;------ |
| 8 | + |
| 9 | +( |
| 10 | + (type_constructor) @type.builtin |
| 11 | + (#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$") |
| 12 | +) |
| 13 | + |
| 14 | +[(class_name) (class_type_name) (type_constructor)] @type |
| 15 | + |
| 16 | +[(constructor_name) (tag)] @constructor |
| 17 | + |
| 18 | +; Functions |
| 19 | +;---------- |
| 20 | + |
| 21 | +(let_binding |
| 22 | + pattern: (value_name) @function |
| 23 | + (parameter)) |
| 24 | + |
| 25 | +(let_binding |
| 26 | + pattern: (value_name) @function |
| 27 | + body: [(fun_expression) (function_expression)]) |
| 28 | + |
| 29 | +(value_specification (value_name) @function) |
| 30 | + |
| 31 | +(external (value_name) @function) |
| 32 | + |
| 33 | +(method_name) @function.method |
| 34 | + |
| 35 | +; Application |
| 36 | +;------------ |
| 37 | + |
| 38 | +( |
| 39 | + (value_name) @function.builtin |
| 40 | + (#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$") |
| 41 | +) |
| 42 | + |
| 43 | +(infix_expression |
| 44 | + left: (value_path (value_name) @function) |
| 45 | + operator: (concat_operator) @operator |
| 46 | + (#eq? @operator "@@")) |
| 47 | + |
| 48 | +(infix_expression |
| 49 | + operator: (rel_operator) @operator |
| 50 | + right: (value_path (value_name) @function) |
| 51 | + (#eq? @operator "|>")) |
| 52 | + |
| 53 | +(application_expression |
| 54 | + function: (value_path (value_name) @function)) |
| 55 | + |
| 56 | +; Variables |
| 57 | +;---------- |
| 58 | + |
| 59 | +[(value_name) (type_variable)] @variable |
| 60 | + |
| 61 | +(value_pattern) @variable.parameter |
| 62 | + |
| 63 | +; Properties |
| 64 | +;----------- |
| 65 | + |
| 66 | +[(label_name) (field_name) (instance_variable_name)] @property |
| 67 | + |
| 68 | +; Constants |
| 69 | +;---------- |
| 70 | + |
| 71 | +(boolean) @constant |
| 72 | + |
| 73 | +[(number) (signed_number)] @number |
| 74 | + |
| 75 | +[(string) (character)] @string |
| 76 | + |
| 77 | +(quoted_string "{" @string "}" @string) @string |
| 78 | + |
| 79 | +(escape_sequence) @escape |
| 80 | + |
| 81 | +(conversion_specification) @string.special |
| 82 | + |
| 83 | +; Operators |
| 84 | +;---------- |
| 85 | + |
| 86 | +(match_expression (match_operator) @keyword) |
| 87 | + |
| 88 | +(value_definition [(let_operator) (let_and_operator)] @keyword) |
| 89 | + |
| 90 | +[ |
| 91 | + (prefix_operator) |
| 92 | + (sign_operator) |
| 93 | + (pow_operator) |
| 94 | + (mult_operator) |
| 95 | + (add_operator) |
| 96 | + (concat_operator) |
| 97 | + (rel_operator) |
| 98 | + (and_operator) |
| 99 | + (or_operator) |
| 100 | + (assign_operator) |
| 101 | + (hash_operator) |
| 102 | + (indexing_operator) |
| 103 | + (let_operator) |
| 104 | + (let_and_operator) |
| 105 | + (match_operator) |
| 106 | +] @operator |
| 107 | + |
| 108 | +["*" "#" "::" "<-"] @operator |
| 109 | + |
| 110 | +; Keywords |
| 111 | +;--------- |
| 112 | + |
| 113 | +[ |
| 114 | + "and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else" |
| 115 | + "end" "exception" "external" "for" "fun" "function" "functor" "if" "in" |
| 116 | + "include" "inherit" "initializer" "lazy" "let" "match" "method" "module" |
| 117 | + "mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct" |
| 118 | + "then" "to" "try" "type" "val" "virtual" "when" "while" "with" |
| 119 | +] @keyword |
| 120 | + |
| 121 | +; Punctuation |
| 122 | +;------------ |
| 123 | + |
| 124 | +(attribute ["[@" "]"] @punctuation.special) |
| 125 | +(item_attribute ["[@@" "]"] @punctuation.special) |
| 126 | +(floating_attribute ["[@@@" "]"] @punctuation.special) |
| 127 | +(extension ["[%" "]"] @punctuation.special) |
| 128 | +(item_extension ["[%%" "]"] @punctuation.special) |
| 129 | +(quoted_extension ["{%" "}"] @punctuation.special) |
| 130 | +(quoted_item_extension ["{%%" "}"] @punctuation.special) |
| 131 | + |
| 132 | +"%" @punctuation.special |
| 133 | + |
| 134 | +["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket |
| 135 | + |
| 136 | +(object_type ["<" ">"] @punctuation.bracket) |
| 137 | + |
| 138 | +[ |
| 139 | + "," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&" |
| 140 | + "->" ";;" ":>" "+=" ":=" ".." |
| 141 | +] @punctuation.delimiter |
| 142 | + |
| 143 | +; Attributes |
| 144 | +;----------- |
| 145 | + |
| 146 | +(attribute_id) @tag |
| 147 | + |
| 148 | +; Comments |
| 149 | +;--------- |
| 150 | + |
| 151 | +[(comment) (line_number_directive) (directive) (shebang)] @comment |
0 commit comments