on master help sign in
Add OpenCL tree-sitter and LSP config (#6473)
fff8543lefp
book/src/generated/lang-support.md+1
@@ -97,6 +97,7 @@
97| ocaml | ✓ | | ✓ | `ocamllsp` |
97| ocaml | ✓ | | ✓ | `ocamllsp` |
98| ocaml-interface | ✓ | | | `ocamllsp` |
98| ocaml-interface | ✓ | | | `ocamllsp` |
99| odin | ✓ | | | `ols` |
99| odin | ✓ | | | `ols` |
100+| opencl | ✓ | ✓ | ✓ | `clangd` |
100| openscad | ✓ | | | `openscad-lsp` |
101| openscad | ✓ | | | `openscad-lsp` |
101| org | ✓ | | | |
102| org | ✓ | | | |
102| pascal | ✓ | ✓ | | `pasls` |
103| pascal | ✓ | ✓ | | `pasls` |
languages.toml+13
@@ -2472,3 +2472,16 @@ language-server = { command = "markdoc-ls", args = ["--stdio"] }
2472[[grammar]]
2472[[grammar]]
2473name = "markdoc"
2473name = "markdoc"
2474source = { git = "https://github.com/markdoc-extra/tree-sitter-markdoc", rev = "5ffe71b29e8a3f94823913ea9cea51fcfa7e3bf8" }
2474source = { git = "https://github.com/markdoc-extra/tree-sitter-markdoc", rev = "5ffe71b29e8a3f94823913ea9cea51fcfa7e3bf8" }
2475+
2476+[[language]]
2477+name = "opencl"
2478+scope = "source.cl"
2479+injection-regex = "(cl|opencl)"
2480+file-types = ["cl"]
2481+roots = []
2482+comment-token = "//"
2483+language-server = { command = "clangd" }
2484+
2485+[[grammar]]
2486+name = "opencl"
2487+source = { git = "https://github.com/lefp/tree-sitter-opencl", rev = "8e1d24a57066b3cd1bb9685bbc1ca9de5c1b78fb" }
runtime/queries/opencl/highlights.scmnew file+150
@@ -0,0 +1,150 @@
1+[
2+ "sizeof"
3+ ; @todo why does "uniform" break highlighting?
4+ ; "uniform" ; OpenCL C 3.0.13 reserves this as a keyword, but doesn't seem to use it for anything
5+ (function_qualifier)
6+] @keyword
7+
8+[
9+ "enum"
10+ "struct"
11+ "typedef"
12+ "union"
13+] @keyword.storage.type
14+
15+[
16+ "extern"
17+ "register"
18+ (type_qualifier)
19+ (access_qualifier)
20+ (storage_class_specifier)
21+ (address_space_qualifier)
22+] @keyword.storage.modifier
23+
24+[
25+ "goto"
26+ "break"
27+ "continue"
28+] @keyword.control
29+
30+[
31+ "do"
32+ "for"
33+ "while"
34+] @keyword.control.repeat
35+
36+[
37+ "if"
38+ "else"
39+ "switch"
40+ "case"
41+ "default"
42+] @keyword.control.conditional
43+
44+"return" @keyword.control.return
45+
46+[
47+ "defined"
48+ "#define"
49+ "#elif"
50+ "#else"
51+ "#endif"
52+ "#if"
53+ "#ifdef"
54+ "#ifndef"
55+ "#include"
56+ (preproc_directive)
57+] @keyword.directive
58+
59+(pointer_declarator "*" @type.builtin)
60+(abstract_pointer_declarator "*" @type.builtin)
61+
62+[
63+ "+"
64+ "-"
65+ "*"
66+ "/"
67+ "++"
68+ "--"
69+ "%"
70+ "=="
71+ "!="
72+ ">"
73+ "<"
74+ ">="
75+ "<="
76+ "&&"
77+ "||"
78+ "!"
79+ "&"
80+ "|"
81+ "^"
82+ "~"
83+ "<<"
84+ ">>"
85+ "="
86+ "+="
87+ "-="
88+ "*="
89+ "/="
90+ "%="
91+ "<<="
92+ ">>="
93+ "&="
94+ "^="
95+ "|="
96+ "?"
97+] @operator
98+
99+(conditional_expression ":" @operator)
100+
101+"..." @punctuation
102+
103+["," "." ":" ";" "->" "::"] @punctuation.delimiter
104+
105+["(" ")" "[" "]" "{" "}"] @punctuation.bracket
106+
107+[(true) (false)] @constant.builtin.boolean
108+
109+(enumerator name: (identifier) @type.enum.variant)
110+
111+(string_literal) @string
112+(system_lib_string) @string
113+
114+(null) @constant
115+(number_literal) @constant.numeric
116+(char_literal) @constant.character
117+
118+(call_expression
119+ function: (identifier) @function)
120+(call_expression
121+ function: (field_expression
122+ field: (field_identifier) @function))
123+(call_expression (argument_list (identifier) @variable))
124+(function_declarator
125+ declarator: [(identifier) (field_identifier)] @function)
126+(parameter_declaration
127+ declarator: (identifier) @variable.parameter)
128+(parameter_declaration
129+ (pointer_declarator
130+ declarator: (identifier) @variable.parameter))
131+(preproc_function_def
132+ name: (identifier) @function.special)
133+
134+(attribute
135+ name: (identifier) @attribute)
136+
137+(field_identifier) @variable.other.member
138+(statement_identifier) @label
139+(type_identifier) @type
140+(scalar_type) @type.builtin
141+(sized_type_specifier) @type.builtin
142+(vector_type) @type.builtin
143+(other_builtin_type) @type.builtin
144+
145+((identifier) @constant
146+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
147+
148+(identifier) @variable
149+
150+(comment) @comment
runtime/queries/opencl/indents.scmnew file+1
@@ -0,0 +1 @@
1+; inherits: c
runtime/queries/opencl/injections.scmnew file+1
@@ -0,0 +1 @@
1+; inherits: c
runtime/queries/opencl/textobjects.scmnew file+1
@@ -0,0 +1 @@
1+; inherits: c