on master help sign in
Add LLVM TableGen highlighting (#1409)

Add a tree-sitter grammar and highlights for TableGen files. TableGen and its grammar are described here: https://llvm.org/docs/TableGen/index.html Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

commit8f2af713408b8b40cf71873bbc0ddc009a7b3da5 authorSebastian Neubauer <Flakebi@users.noreply.github.com> dateMon 3 Jan 2022, 02:57 (5 years ago) parent93a948d
8 files changed+121
.gitmodules+4 book/src/generated/lang-support.md+1 helix-syntax/languages/tree-sitter-tablegen+1 languages.toml+9 runtime/queries/tablegen/highlights.scm+90 runtime/queries/tablegen/indents.toml+7 runtime/queries/tablegen/injections.scm+2 runtime/queries/tablegen/textobjects.scm+7
.gitmodules+4
@@ -178,6 +178,10 @@
178178 path = helix-syntax/languages/tree-sitter-git-diff
179179 url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
180180 shallow = true
181+[submodule "helix-syntax/languages/tree-sitter-tablegen"]
182+ path = helix-syntax/languages/tree-sitter-tablegen
183+ url = https://github.com/Flakebi/tree-sitter-tablegen
184+ shallow = true
181185[submodule "helix-syntax/languages/tree-sitter-git-rebase"]
182186 path = helix-syntax/languages/tree-sitter-git-rebase
183187 url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git
book/src/generated/lang-support.md+1
@@ -40,6 +40,7 @@
4040| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
4141| scala | ✓ | | ✓ | `metals` |
4242| svelte | ✓ | | ✓ | `svelteserver` |
43+| tablegen | ✓ | ✓ | ✓ | |
4344| toml | ✓ | | | |
4445| tsq | ✓ | | | |
4546| tsx | ✓ | | | `typescript-language-server` |
helix-syntax/languages/tree-sitter-tablegennew file+1

Submodule changed.

languages.toml+9
@@ -436,6 +436,15 @@ file-types = ["ll"]
436436comment-token = ";"
437437indent = { tab-width = 2, unit = " " }
438438
439+[[language]]
440+name = "tablegen"
441+scope = "source.tablegen"
442+roots = []
443+file-types = ["td"]
444+comment-token = "//"
445+indent = { tab-width = 2, unit = " " }
446+injection-regex = "tablegen"
447+
439448[[language]]
440449name = "markdown"
441450scope = "source.md"
runtime/queries/tablegen/highlights.scmnew file+90
@@ -0,0 +1,90 @@
1+[
2+ (comment)
3+ (multiline_comment)
4+] @comment
5+
6+[
7+ "("
8+ ")"
9+ "["
10+ "]"
11+ "{"
12+ "}"
13+ "<"
14+ ">"
15+] @punctuation.bracket
16+
17+[
18+ ","
19+ ";"
20+ "."
21+] @punctuation.delimiter
22+
23+[
24+ "#"
25+ "-"
26+ "..."
27+ ":"
28+] @operator
29+
30+[
31+ "="
32+ "!cond"
33+ (operator_keyword)
34+] @function
35+
36+[
37+ "true"
38+ "false"
39+] @constant.builtin.boolean
40+
41+[
42+ "?"
43+] @constant.builtin
44+
45+(var) @variable
46+
47+(template_arg (identifier) @variable.parameter)
48+
49+(_ argument: (value (identifier) @variable.parameter))
50+
51+(type) @type
52+
53+"code" @type.builtin
54+
55+(number) @constant.numeric.integer
56+[
57+ (string_string)
58+ (code_string)
59+] @string
60+
61+(preprocessor) @keyword.directive
62+
63+[
64+ "class"
65+ "field"
66+ "let"
67+ "defvar"
68+ "def"
69+ "defset"
70+ "defvar"
71+ "assert"
72+] @keyword
73+
74+[
75+ "let"
76+ "in"
77+ "foreach"
78+ "if"
79+ "then"
80+ "else"
81+] @keyword.operator
82+
83+"include" @keyword.control.import
84+
85+[
86+ "multiclass"
87+ "defm"
88+] @namespace
89+
90+(ERROR) @error
runtime/queries/tablegen/indents.tomlnew file+7
@@ -0,0 +1,7 @@
1+indent = [
2+ "statement",
3+]
4+
5+outdent = [
6+ "}",
7+]
runtime/queries/tablegen/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+([ (comment) (multiline_comment)] @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/tablegen/textobjects.scmnew file+7
@@ -0,0 +1,7 @@
1+(class
2+ body: (_) @class.inside) @class.around
3+
4+(multiclass
5+ body: (_) @class.inside) @class.around
6+
7+(_ argument: _ @parameter.inside)