on master help sign in
OCaml support (#666)
5766f5doberblastmeister
.gitmodules+4
@@ -102,6 +102,10 @@
102 path = helix-syntax/languages/tree-sitter-protobuf
102 path = helix-syntax/languages/tree-sitter-protobuf
103 url = https://github.com/yusdacra/tree-sitter-protobuf.git
103 url = https://github.com/yusdacra/tree-sitter-protobuf.git
104 shallow = true
104 shallow = true
105+[submodule "helix-syntax/languages/tree-sitter-ocaml"]
106+ path = helix-syntax/languages/tree-sitter-ocaml
107+ url = https://github.com/tree-sitter/tree-sitter-ocaml
108+ shallow = true
105[submodule "helix-syntax/languages/tree-sitter-lua"]
109[submodule "helix-syntax/languages/tree-sitter-lua"]
106 path = helix-syntax/languages/tree-sitter-lua
110 path = helix-syntax/languages/tree-sitter-lua
107 url = https://github.com/nvim-treesitter/tree-sitter-lua
111 url = https://github.com/nvim-treesitter/tree-sitter-lua
helix-syntax/build.rs+3
@@ -177,6 +177,7 @@ fn main() {
177 let ignore = vec![
177 let ignore = vec![
178 "tree-sitter-typescript".to_string(),
178 "tree-sitter-typescript".to_string(),
179 "tree-sitter-haskell".to_string(), // aarch64 failures: https://github.com/tree-sitter/tree-sitter-haskell/issues/34
179 "tree-sitter-haskell".to_string(), // aarch64 failures: https://github.com/tree-sitter/tree-sitter-haskell/issues/34
180+ "tree-sitter-ocaml".to_string(),
180 ];
181 ];
181 let dirs = collect_tree_sitter_dirs(&ignore).unwrap();
182 let dirs = collect_tree_sitter_dirs(&ignore).unwrap();
182
183
@@ -202,4 +203,6 @@ fn main() {
202
203
203 build_dir("tree-sitter-typescript/tsx", "tsx");
204 build_dir("tree-sitter-typescript/tsx", "tsx");
204 build_dir("tree-sitter-typescript/typescript", "typescript");
205 build_dir("tree-sitter-typescript/typescript", "typescript");
206+ build_dir("tree-sitter-ocaml/ocaml", "ocaml");
207+ build_dir("tree-sitter-ocaml/interface", "ocaml-interface")
205}
208}
helix-syntax/languages/tree-sitter-ocamlnew file+1

Submodule changed.

languages.toml+17
@@ -224,6 +224,23 @@ roots = []
224comment-token = ";"
224comment-token = ";"
225indent = { tab-width = 4, unit = " " }
225indent = { tab-width = 4, unit = " " }
226
226
227+[[language]]
228+name = "ocaml"
229+scope = "source.ocaml"
230+injection-regex = "ocaml"
231+file-types = ["ml"]
232+roots = []
233+comment-token = "(**)"
234+indent = { tab-width = 2, unit = " " }
235+
236+[[language]]
237+name = "ocaml-interface"
238+scope = "source.ocaml.interface"
239+file-types = ["mli"]
240+roots = []
241+comment-token = "(**)"
242+indent = { tab-width = 2, unit = " "}
243+
227[[language]]
244[[language]]
228name = "lua"
245name = "lua"
229scope = "source.lua"
246scope = "source.lua"
runtime/queries/ocaml-interface/highlights.scmnew file+1
@@ -0,0 +1 @@
1+; inherits: ocaml
runtime/queries/ocaml/highlights.scmnew file+160
@@ -0,0 +1,160 @@
1+; Modules
2+;--------
3+
4+[(module_name) (module_type_name)] @namespace
5+
6+; Types
7+;------
8+
9+[(class_name) (class_type_name) (type_constructor)] @type
10+
11+[(constructor_name) (tag)] @constructor
12+
13+; Functions
14+;----------
15+
16+(let_binding
17+ pattern: (value_name) @function
18+ (parameter))
19+
20+(let_binding
21+ pattern: (value_name) @function
22+ body: [(fun_expression) (function_expression)])
23+
24+(value_specification (value_name) @function)
25+
26+(external (value_name) @function)
27+
28+(method_name) @method
29+
30+; Variables
31+;----------
32+
33+(value_pattern) @parameter
34+
35+; Application
36+;------------
37+
38+(infix_expression
39+ left: (value_path (value_name) @function)
40+ (infix_operator) @operator
41+ (#eq? @operator "@@"))
42+
43+(infix_expression
44+ (infix_operator) @operator
45+ right: (value_path (value_name) @function)
46+ (#eq? @operator "|>"))
47+
48+(application_expression
49+ function: (value_path (value_name) @function))
50+
51+; Properties
52+;-----------
53+
54+[(label_name) (field_name) (instance_variable_name)] @property
55+
56+; Constants
57+;----------
58+
59+[(boolean) (unit)] @constant
60+
61+[(number) (signed_number)] @number
62+
63+(character) @character
64+
65+(string) @string
66+
67+(quoted_string "{" @string "}" @string) @string
68+
69+(escape_sequence) @string.escape
70+
71+[
72+ (conversion_specification)
73+ (pretty_printing_indication)
74+] @punctuation.special
75+
76+; Keywords
77+;---------
78+
79+[
80+ "and" "as" "assert" "begin" "class" "constraint"
81+ "end" "external" "in"
82+ "inherit" "initializer" "lazy" "let" "match" "method" "module"
83+ "mutable" "new" "nonrec" "object" "of" "private" "rec" "sig" "struct"
84+ "type" "val" "virtual" "when" "with"
85+] @keyword
86+
87+["fun" "function" "functor"] @keyword.function
88+
89+["if" "then" "else"] @keyword.control.conditional
90+
91+["exception" "try"] @keyword.control.exception
92+
93+["include" "open"] @include
94+
95+["for" "to" "downto" "while" "do" "done"] @keyword.control.loop
96+
97+; Macros
98+;-------
99+
100+(attribute ["[@" "]"] @attribute)
101+(item_attribute ["[@@" "]"] @attribute)
102+(floating_attribute ["[@@@" "]"] @attribute)
103+(extension ["[%" "]"] @function.macro)
104+(item_extension ["[%%" "]"] @function.macro)
105+(quoted_extension ["{%" "}"] @function.macro)
106+(quoted_item_extension ["{%%" "}"] @function.macro)
107+"%" @function.macro
108+
109+["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
110+
111+(object_type ["<" ">"] @punctuation.bracket)
112+
113+[
114+ "," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
115+ "->" ";;" ":>" "+=" ":=" ".."
116+] @punctuation.delimiter
117+
118+; Operators
119+;----------
120+
121+[
122+ (prefix_operator)
123+ (sign_operator)
124+ (infix_operator)
125+ (hash_operator)
126+ (indexing_operator)
127+ (let_operator)
128+ (and_operator)
129+ (match_operator)
130+] @operator
131+
132+(match_expression (match_operator) @keyword)
133+
134+(value_definition [(let_operator) (and_operator)] @keyword)
135+
136+;; TODO: this is an error now
137+;(prefix_operator "!" @operator)
138+
139+(infix_operator ["&" "+" "-" "=" ">" "|" "%"] @operator)
140+
141+(signed_number ["+" "-"] @operator)
142+
143+["*" "#" "::" "<-"] @operator
144+
145+; Attributes
146+;-----------
147+
148+(attribute_id) @property
149+
150+; Comments
151+;---------
152+
153+[(comment) (line_number_directive) (directive) (shebang)] @comment
154+
155+(ERROR) @error
156+
157+; Blanket highlights
158+; ------------------
159+
160+[(value_name) (type_variable)] @variable
runtime/queries/ocaml/indents.tomlnew file+13
@@ -0,0 +1,13 @@
1+indent = [
2+ "let_binding",
3+ "type_binding",
4+ "structure",
5+ "signature",
6+ "record_declaration",
7+ "function_expression",
8+ "match_case",
9+]
10+
11+oudent = [
12+ "}",
13+]
runtime/queries/ocaml/locals.scmnew file+24
@@ -0,0 +1,24 @@
1+; Scopes
2+;-------
3+
4+[
5+ (let_binding)
6+ (class_binding)
7+ (class_function)
8+ (method_definition)
9+ (fun_expression)
10+ (object_expression)
11+ (for_expression)
12+ (match_case)
13+ (attribute_payload)
14+] @local.scope
15+
16+; Definitions
17+;------------
18+
19+(value_pattern) @local.definition
20+
21+; References
22+;-----------
23+
24+(value_path . (value_name) @local.reference)