Skip to content

Commit 9c50300

Browse files
Copy Missing tree-sitter Queries From nvim-treesitter (with attribution) (#87)
### Description This PR introduces a new build step, where missing tree-sitter query files are copied from nvim-treesitter. Neovim has done an amazing job curating good tree-sitter language support through queries. They use the same parsers we do, but have implemented a few more queries on top of the ones implemented in the parent language repositories. I don't want to look like we're just stealing the work neovim has done. Neovim is under the Apache 2.0 license, and each query file used from their project is copied with a copyright notice directing contributors to their repository. Hopefully the sharing of query files means issues found in CodeEdit will be fixed for Neovim as well. ### Related Issues * CodeEditApp/CodeEditSourceEditor#43 - required to implement code folding using tree-sitter. ### Checklist - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots
1 parent 05918bb commit 9c50300

101 files changed

Lines changed: 6089 additions & 38 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
3.64 KB
Binary file not shown.

Sources/CodeEditLanguages/CodeLanguage+Definitions.swift

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public extension CodeLanguage {
6262
tsName: "agda",
6363
extensions: ["agda"],
6464
lineCommentString: "--",
65-
rangeCommentStrings: ("{-", "-}")
65+
rangeCommentStrings: ("{-", "-}"),
66+
highlights: ["folds", "injections"]
6667
)
6768

6869
/// A language structure for `Bash`
@@ -71,7 +72,8 @@ public extension CodeLanguage {
7172
tsName: "bash",
7273
extensions: ["sh", "bash"],
7374
lineCommentString: "#",
74-
rangeCommentStrings: (":'", "'")
75+
rangeCommentStrings: (":'", "'"),
76+
highlights: ["folds", "injections", "locals"]
7577
)
7678

7779
/// A language structure for `C`
@@ -80,7 +82,8 @@ public extension CodeLanguage {
8082
tsName: "c",
8183
extensions: ["c", "h"],
8284
lineCommentString: "//",
83-
rangeCommentStrings: ("/*", "*/")
85+
rangeCommentStrings: ("/*", "*/"),
86+
highlights: ["folds", "indents", "injections", "locals", "tags"]
8487
)
8588

8689
/// A language structure for `C++`
@@ -92,7 +95,7 @@ public extension CodeLanguage {
9295
rangeCommentStrings: CodeLanguage.c.rangeCommentStrings,
9396
documentationCommentStrings: [.pair(("/**", "*/"))],
9497
parentURL: CodeLanguage.c.queryURL,
95-
highlights: ["injections"]
98+
highlights: ["folds", "indents", "injections", "locals", "tags"]
9699
)
97100

98101
/// A language structure for `C#`
@@ -101,7 +104,8 @@ public extension CodeLanguage {
101104
tsName: "c-sharp",
102105
extensions: ["cs"],
103106
lineCommentString: "//",
104-
rangeCommentStrings: ("/*", "*/")
107+
rangeCommentStrings: ("/*", "*/"),
108+
highlights: ["folds", "injections", "locals", "tags"]
105109
)
106110

107111
/// A language structure for `CSS`
@@ -110,7 +114,8 @@ public extension CodeLanguage {
110114
tsName: "css",
111115
extensions: ["css"],
112116
lineCommentString: "",
113-
rangeCommentStrings: ("/*", "*/")
117+
rangeCommentStrings: ("/*", "*/"),
118+
highlights: ["folds", "indents", "injections"]
114119
)
115120

116121
/// A language structure for `Dart`
@@ -119,7 +124,8 @@ public extension CodeLanguage {
119124
tsName: "dart",
120125
extensions: ["dart"],
121126
lineCommentString: "//",
122-
rangeCommentStrings: ("/*", "*/")
127+
rangeCommentStrings: ("/*", "*/"),
128+
highlights: ["folds", "indents", "injections", "locals", "tags"]
123129
)
124130

125131
/// A language structure for `Dockerfile`
@@ -128,7 +134,8 @@ public extension CodeLanguage {
128134
tsName: "dockerfile",
129135
extensions: ["Dockerfile"],
130136
lineCommentString: "#",
131-
rangeCommentStrings: ("", "")
137+
rangeCommentStrings: ("", ""),
138+
highlights: ["injections"]
132139
)
133140

134141
/// A language structure for `Elixir`
@@ -139,7 +146,7 @@ public extension CodeLanguage {
139146
lineCommentString: "#",
140147
rangeCommentStrings: ("", ""),
141148
documentationCommentStrings: [.pair(("\"\"\"", "\"\"\""))],
142-
highlights: ["injections"]
149+
highlights: ["folds", "indents", "injections", "locals", "tags"]
143150
)
144151

145152
/// A language structure for `Go`
@@ -148,7 +155,8 @@ public extension CodeLanguage {
148155
tsName: "go",
149156
extensions: ["go"],
150157
lineCommentString: "//",
151-
rangeCommentStrings: ("/*", "*/")
158+
rangeCommentStrings: ("/*", "*/"),
159+
highlights: ["folds", "indents", "injections", "locals", "tags"]
152160
)
153161

154162
/// A language structure for `GoMod`
@@ -166,7 +174,8 @@ public extension CodeLanguage {
166174
tsName: "haskell",
167175
extensions: ["hs"],
168176
lineCommentString: "--",
169-
rangeCommentStrings: ("{-", "-}")
177+
rangeCommentStrings: ("{-", "-}"),
178+
highlights: ["folds", "injections", "locals"]
170179
)
171180

172181
/// A language structure for `HTML`
@@ -176,7 +185,7 @@ public extension CodeLanguage {
176185
extensions: ["html", "htm", "shtml"],
177186
lineCommentString: "",
178187
rangeCommentStrings: ("<!--", "-->"),
179-
highlights: ["injections"]
188+
highlights: ["folds", "indents", "injections", "locals"]
180189
)
181190

182191
/// A language structure for `Java`
@@ -186,7 +195,8 @@ public extension CodeLanguage {
186195
extensions: ["java", "jav"],
187196
lineCommentString: "//",
188197
rangeCommentStrings: ("/*", "*/"),
189-
documentationCommentStrings: [.pair(("/**", "*/"))]
198+
documentationCommentStrings: [.pair(("/**", "*/"))],
199+
highlights: ["folds", "indents", "injections", "locals", "tags"]
190200
)
191201

192202
/// A language structure for `JavaScript`
@@ -197,7 +207,7 @@ public extension CodeLanguage {
197207
lineCommentString: "//",
198208
rangeCommentStrings: ("/*", "*/"),
199209
documentationCommentStrings: [.pair(("/**", "*/"))],
200-
highlights: ["injections"],
210+
highlights: ["folds", "indents", "injections", "locals", "tags"],
201211
additionalIdentifiers: ["node", "deno"]
202212
)
203213

@@ -216,7 +226,8 @@ public extension CodeLanguage {
216226
tsName: "json",
217227
extensions: ["json"],
218228
lineCommentString: "//",
219-
rangeCommentStrings: ("/*", "*/")
229+
rangeCommentStrings: ("/*", "*/"),
230+
highlights: ["folds", "indents", "locals"]
220231
)
221232

222233
/// A language structure for `JSX`
@@ -226,7 +237,7 @@ public extension CodeLanguage {
226237
extensions: ["jsx"],
227238
lineCommentString: "//",
228239
rangeCommentStrings: ("/*", "*/"),
229-
highlights: ["highlights-jsx", "injections"]
240+
highlights: ["folds", "highlights-jsx", "indents", "injections", "locals", "tags"]
230241
)
231242

232243
/// A language structure for `Julia`
@@ -235,7 +246,8 @@ public extension CodeLanguage {
235246
tsName: "julia",
236247
extensions: ["jl"],
237248
lineCommentString: "#",
238-
rangeCommentStrings: ("#=", "=#")
249+
rangeCommentStrings: ("#=", "=#"),
250+
highlights: ["folds", "indents", "injections", "locals"]
239251
)
240252

241253
/// A language structure for `Kotlin`
@@ -244,7 +256,8 @@ public extension CodeLanguage {
244256
tsName: "kotlin",
245257
extensions: ["kt", "kts"],
246258
lineCommentString: "//",
247-
rangeCommentStrings: ("/*", "*/")
259+
rangeCommentStrings: ("/*", "*/"),
260+
highlights: ["folds", "injections", "locals"]
248261
)
249262

250263
/// A language structure for `Lua`
@@ -254,7 +267,7 @@ public extension CodeLanguage {
254267
extensions: ["lua"],
255268
lineCommentString: "--",
256269
rangeCommentStrings: ("-[[", "]]--"),
257-
highlights: ["injections"]
270+
highlights: ["folds", "indents", "injections", "locals", "tags"]
258271
)
259272

260273
/// A language structure for `Markdown`
@@ -264,7 +277,7 @@ public extension CodeLanguage {
264277
extensions: ["md", "mkd", "mkdn", "mdwn", "mdown", "markdown"],
265278
lineCommentString: "[comment]: #",
266279
rangeCommentStrings: ("", ""),
267-
highlights: ["injections"]
280+
highlights: ["folds", "indents", "injections"]
268281
)
269282

270283
/// A language structure for `Markdown Inline`
@@ -285,7 +298,7 @@ public extension CodeLanguage {
285298
lineCommentString: "//",
286299
rangeCommentStrings: ("/*", "*/"),
287300
parentURL: CodeLanguage.c.queryURL,
288-
highlights: ["injections"]
301+
highlights: ["folds", "indents", "injections", "locals"]
289302
)
290303

291304
/// A language structure for `OCaml`
@@ -295,7 +308,8 @@ public extension CodeLanguage {
295308
extensions: ["ml"],
296309
lineCommentString: "",
297310
rangeCommentStrings: ("(*", "*)"),
298-
documentationCommentStrings: [.pair(("(**", "*)"))]
311+
documentationCommentStrings: [.pair(("(**", "*)"))],
312+
highlights: ["folds", "indents", "injections", "locals", "tags"]
299313
)
300314

301315
/// A language structure for `OCaml Interface`
@@ -304,7 +318,8 @@ public extension CodeLanguage {
304318
tsName: "ocaml",
305319
extensions: ["mli"],
306320
lineCommentString: "",
307-
rangeCommentStrings: ("", "")
321+
rangeCommentStrings: ("", ""),
322+
highlights: ["folds", "indents", "injections", "locals", "tags"]
308323
)
309324

310325
/// A language structure for `Perl`
@@ -313,7 +328,8 @@ public extension CodeLanguage {
313328
tsName: "perl",
314329
extensions: ["pl", "pm"],
315330
lineCommentString: "#",
316-
rangeCommentStrings: ("=pod", "=cut")
331+
rangeCommentStrings: ("=pod", "=cut"),
332+
highlights: ["folds", "injections"]
317333
)
318334

319335
/// A language structure for `PHP`
@@ -323,7 +339,7 @@ public extension CodeLanguage {
323339
extensions: ["php"],
324340
lineCommentString: "//",
325341
rangeCommentStrings: ("/*", "*/"),
326-
highlights: ["injections"]
342+
highlights: ["folds", "indents", "injections", "locals", "tags"]
327343
)
328344

329345
/// A language structure for `Python`
@@ -334,6 +350,7 @@ public extension CodeLanguage {
334350
lineCommentString: "#",
335351
rangeCommentStrings: ("", ""),
336352
documentationCommentStrings: [.pair(("\"\"\"", "\"\"\""))],
353+
highlights: ["folds", "indents", "injections", "locals", "tags"],
337354
additionalIdentifiers: ["python2", "python3"]
338355
)
339356

@@ -352,7 +369,8 @@ public extension CodeLanguage {
352369
tsName: "ruby",
353370
extensions: ["rb"],
354371
lineCommentString: "#",
355-
rangeCommentStrings: ("=begin", "=end")
372+
rangeCommentStrings: ("=begin", "=end"),
373+
highlights: ["folds", "indents", "injections", "locals", "tags"]
356374
)
357375

358376
/// A language structure for `Rust`
@@ -368,7 +386,7 @@ public extension CodeLanguage {
368386
.pair(("/**", "*/")),
369387
.pair(("/*!", "*/"))
370388
],
371-
highlights: ["injections"]
389+
highlights: ["folds", "indents", "injections", "locals", "tags"]
372390
)
373391

374392
/// A language structure for `Scala`
@@ -377,7 +395,8 @@ public extension CodeLanguage {
377395
tsName: "scala",
378396
extensions: ["scala", "sc"],
379397
lineCommentString: "//",
380-
rangeCommentStrings: ("/*", "*/")
398+
rangeCommentStrings: ("/*", "*/"),
399+
highlights: ["folds", "injections", "locals"]
381400
)
382401

383402
/// A language structure for `SQL`
@@ -386,7 +405,8 @@ public extension CodeLanguage {
386405
tsName: "sql",
387406
extensions: ["sql"],
388407
lineCommentString: "--",
389-
rangeCommentStrings: ("/*", "*/")
408+
rangeCommentStrings: ("/*", "*/"),
409+
highlights: ["folds", "indents", "injections"]
390410
)
391411

392412
/// A language structure for `Swift`
@@ -396,7 +416,8 @@ public extension CodeLanguage {
396416
extensions: ["swift"],
397417
lineCommentString: "//",
398418
rangeCommentStrings: ("/*", "*/"),
399-
documentationCommentStrings: [.single("///"), .pair(("/**", "*/"))]
419+
documentationCommentStrings: [.single("///"), .pair(("/**", "*/"))],
420+
highlights: ["folds", "indents", "injections", "locals", "tags"]
400421
)
401422

402423
/// A language structure for `TOML`
@@ -405,7 +426,8 @@ public extension CodeLanguage {
405426
tsName: "toml",
406427
extensions: ["toml"],
407428
lineCommentString: "#",
408-
rangeCommentStrings: ("", "")
429+
rangeCommentStrings: ("", ""),
430+
highlights: ["folds", "indents", "injections", "locals"]
409431
)
410432

411433
/// A language structure for `TSX`
@@ -415,7 +437,8 @@ public extension CodeLanguage {
415437
extensions: ["tsx"],
416438
lineCommentString: "//",
417439
rangeCommentStrings: ("/*", "*/"),
418-
parentURL: CodeLanguage.jsx.queryURL
440+
parentURL: CodeLanguage.jsx.queryURL,
441+
highlights: ["folds", "indents", "injections", "locals", "tags"]
419442
)
420443

421444
/// A language structure for `Typescript`
@@ -425,7 +448,8 @@ public extension CodeLanguage {
425448
extensions: ["ts", "cts", "mts"],
426449
lineCommentString: "//",
427450
rangeCommentStrings: ("/*", "*/"),
428-
parentURL: CodeLanguage.javascript.queryURL
451+
parentURL: CodeLanguage.javascript.queryURL,
452+
highlights: ["folds", "indents", "injections", "locals", "tags"]
429453
)
430454

431455
/// A language structure for `Verilog`
@@ -434,7 +458,8 @@ public extension CodeLanguage {
434458
tsName: "verilog",
435459
extensions: ["v"],
436460
lineCommentString: "//",
437-
rangeCommentStrings: ("/*", "*/")
461+
rangeCommentStrings: ("/*", "*/"),
462+
highlights: ["folds", "injections"]
438463
)
439464

440465
/// A language structure for `YAML`
@@ -443,7 +468,8 @@ public extension CodeLanguage {
443468
tsName: "yaml",
444469
extensions: ["yml", "yaml"],
445470
lineCommentString: "#",
446-
rangeCommentStrings: ("", "")
471+
rangeCommentStrings: ("", ""),
472+
highlights: ["folds", "indents", "injections", "locals"]
447473
)
448474

449475
/// A language structure for `Zig`
@@ -454,7 +480,7 @@ public extension CodeLanguage {
454480
lineCommentString: "//",
455481
rangeCommentStrings: ("", ""),
456482
documentationCommentStrings: [.single("///"), .single("//!")],
457-
highlights: ["injections"]
483+
highlights: ["folds", "indents", "injections", "locals"]
458484
)
459485

460486
/// The default language (plain text)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; Copyright 2025 nvim-treesitter
2+
;
3+
; Licensed under the Apache License, Version 2.0 (the "License");
4+
; you may not use this file except in compliance with the License.
5+
; You may obtain a copy of the License at
6+
;
7+
; http://www.apache.org/licenses/LICENSE-2.0
8+
;
9+
; Unless required by applicable law or agreed to in writing, software
10+
; distributed under the License is distributed on an "AS IS" BASIS,
11+
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
; See the License for the specific language governing permissions and
13+
; limitations under the License.
14+
15+
16+
[
17+
(record)
18+
(module)
19+
] @fold
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; Copyright 2025 nvim-treesitter
2+
;
3+
; Licensed under the Apache License, Version 2.0 (the "License");
4+
; you may not use this file except in compliance with the License.
5+
; You may obtain a copy of the License at
6+
;
7+
; http://www.apache.org/licenses/LICENSE-2.0
8+
;
9+
; Unless required by applicable law or agreed to in writing, software
10+
; distributed under the License is distributed on an "AS IS" BASIS,
11+
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
; See the License for the specific language governing permissions and
13+
; limitations under the License.
14+
15+
16+
((comment) @injection.content
17+
(#set! injection.language "comment"))

0 commit comments

Comments
 (0)