Skip to content

Commit 066699e

Browse files
authored
Update queries for tree-sitter 0.21.0 (#85)
1 parent 9965d20 commit 066699e

File tree

3 files changed

+111
-103
lines changed

3 files changed

+111
-103
lines changed

package.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"author": "Max Brunsfeld",
1010
"license": "MIT",
1111
"dependencies": {
12-
"nan": "^2.17.0"
12+
"nan": "^2.19.0"
1313
},
1414
"devDependencies": {
15-
"tree-sitter-cli": ">=0.20.8"
15+
"tree-sitter-cli": ">=0.21.0"
1616
},
1717
"scripts": {
1818
"build": "npm run build-ocaml && npm run build-interface",
@@ -26,20 +26,31 @@
2626
"tree-sitter": [
2727
{
2828
"scope": "source.ocaml",
29+
"path": "ocaml",
30+
"external-files": [
31+
"common/scanner.h"
32+
],
2933
"file-types": [
3034
"ml"
3135
],
32-
"first-line-regex": "",
33-
"path": "ocaml",
34-
"injection-regex": "^(ocaml|ml)$"
36+
"injection-regex": "^(ocaml|ml)$",
37+
"highlights": "queries/highlights.scm",
38+
"locals": "queries/locals.scm",
39+
"tags": "queries/tags.scm"
3540
},
3641
{
3742
"scope": "source.ocaml.interface",
43+
"path": "interface",
44+
"external-files": [
45+
"common/scanner.h"
46+
],
3847
"file-types": [
3948
"mli"
4049
],
41-
"path": "interface",
42-
"injection-regex": "^ocaml_interface$"
50+
"injection-regex": "^ocaml_interface$",
51+
"highlights": "queries/highlights.scm",
52+
"locals": "queries/locals.scm",
53+
"tags": "queries/tags.scm"
4354
}
4455
]
4556
}

queries/highlights.scm

Lines changed: 92 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,77 @@
1-
; Modules
2-
;--------
1+
; Punctuation
2+
;------------
33

4-
[(module_name) (module_type_name)] @module
4+
[
5+
"," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
6+
"->" ";;" ":>" "+=" ":=" ".."
7+
] @punctuation.delimiter
58

6-
; Types
7-
;------
9+
["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
810

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-
)
11+
(object_type ["<" ">"] @punctuation.bracket)
1312

14-
[(class_name) (class_type_name) (type_constructor)] @type
13+
"%" @punctuation.special
1514

16-
[(constructor_name) (tag)] @constructor
15+
(attribute ["[@" "]"] @punctuation.special)
16+
(item_attribute ["[@@" "]"] @punctuation.special)
17+
(floating_attribute ["[@@@" "]"] @punctuation.special)
18+
(extension ["[%" "]"] @punctuation.special)
19+
(item_extension ["[%%" "]"] @punctuation.special)
20+
(quoted_extension ["{%" "}"] @punctuation.special)
21+
(quoted_item_extension ["{%%" "}"] @punctuation.special)
1722

18-
; Functions
23+
; Keywords
24+
;---------
25+
26+
[
27+
"and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else"
28+
"end" "exception" "external" "for" "fun" "function" "functor" "if" "in"
29+
"include" "inherit" "initializer" "lazy" "let" "match" "method" "module"
30+
"mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct"
31+
"then" "to" "try" "type" "val" "virtual" "when" "while" "with"
32+
] @keyword
33+
34+
; Operators
1935
;----------
2036

21-
(let_binding
22-
pattern: (value_name) @function
23-
(parameter))
37+
[
38+
(prefix_operator)
39+
(sign_operator)
40+
(pow_operator)
41+
(mult_operator)
42+
(add_operator)
43+
(concat_operator)
44+
(rel_operator)
45+
(and_operator)
46+
(or_operator)
47+
(assign_operator)
48+
(hash_operator)
49+
(indexing_operator)
50+
(let_operator)
51+
(let_and_operator)
52+
(match_operator)
53+
] @operator
2454

25-
(let_binding
26-
pattern: (value_name) @function
27-
body: [(fun_expression) (function_expression)])
55+
(match_expression (match_operator) @keyword)
2856

29-
(value_specification (value_name) @function)
57+
(value_definition [(let_operator) (let_and_operator)] @keyword)
3058

31-
(external (value_name) @function)
59+
["*" "#" "::" "<-"] @operator
3260

33-
(method_name) @function.method
61+
; Constants
62+
;----------
3463

35-
; Application
36-
;------------
64+
(boolean) @constant
3765

38-
(
39-
(value_name) @function.builtin
40-
(#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
41-
)
66+
[(number) (signed_number)] @number
4267

43-
(infix_expression
44-
left: (value_path (value_name) @function)
45-
operator: (concat_operator) @operator
46-
(#eq? @operator "@@"))
68+
[(string) (character)] @string
4769

48-
(infix_expression
49-
operator: (rel_operator) @operator
50-
right: (value_path (value_name) @function)
51-
(#eq? @operator "|>"))
70+
(quoted_string "{" @string "}" @string) @string
5271

53-
(application_expression
54-
function: (value_path (value_name) @function))
72+
(escape_sequence) @escape
73+
74+
(conversion_specification) @string.special
5575

5676
; Variables
5777
;----------
@@ -65,80 +85,57 @@
6585

6686
[(label_name) (field_name) (instance_variable_name)] @property
6787

68-
; Constants
88+
; Functions
6989
;----------
7090

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
91+
(let_binding
92+
pattern: (value_name) @function
93+
(parameter))
8094

81-
(conversion_specification) @string.special
95+
(let_binding
96+
pattern: (value_name) @function
97+
body: [(fun_expression) (function_expression)])
8298

83-
; Operators
84-
;----------
99+
(value_specification (value_name) @function)
85100

86-
(match_expression (match_operator) @keyword)
101+
(external (value_name) @function)
87102

88-
(value_definition [(let_operator) (let_and_operator)] @keyword)
103+
(method_name) @function.method
89104

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
105+
(application_expression
106+
function: (value_path (value_name) @function))
107107

108-
["*" "#" "::" "<-"] @operator
108+
(infix_expression
109+
left: (value_path (value_name) @function)
110+
operator: (concat_operator) @operator
111+
(#eq? @operator "@@"))
109112

110-
; Keywords
111-
;---------
113+
(infix_expression
114+
operator: (rel_operator) @operator
115+
right: (value_path (value_name) @function)
116+
(#eq? @operator "|>"))
112117

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
118+
(
119+
(value_name) @function.builtin
120+
(#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
121+
)
120122

121-
; Punctuation
122-
;------------
123+
; Types
124+
;------
123125

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)
126+
[(class_name) (class_type_name) (type_constructor)] @type
131127

132-
"%" @punctuation.special
128+
(
129+
(type_constructor) @type.builtin
130+
(#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$")
131+
)
133132

134-
["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
133+
[(constructor_name) (tag)] @constructor
135134

136-
(object_type ["<" ">"] @punctuation.bracket)
135+
; Modules
136+
;--------
137137

138-
[
139-
"," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
140-
"->" ";;" ":>" "+=" ":=" ".."
141-
] @punctuation.delimiter
138+
[(module_name) (module_type_name)] @module
142139

143140
; Attributes
144141
;-----------

queries/tags.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(module_path (module_name) @name) @reference.module
1111

12-
; Modules types
12+
; Module types
1313
;--------------
1414

1515
(

0 commit comments

Comments
 (0)