Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add LLVM TableGen highlighting #1409

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
path = helix-syntax/languages/tree-sitter-git-diff
url = https://github.com/the-mikedavis/tree-sitter-git-diff.git
shallow = true
[submodule "helix-syntax/languages/tree-sitter-tablegen"]
path = helix-syntax/languages/tree-sitter-tablegen
url = https://github.com/Flakebi/tree-sitter-tablegen
shallow = true
[submodule "helix-syntax/languages/tree-sitter-git-rebase"]
path = helix-syntax/languages/tree-sitter-git-rebase
url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git
Expand Down
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
| scala | ✓ | | ✓ | `metals` |
| svelte | ✓ | | ✓ | `svelteserver` |
| tablegen | ✓ | ✓ | ✓ | |
| toml | ✓ | | | |
| tsq | ✓ | | | |
| tsx | ✓ | | | `typescript-language-server` |
Expand Down
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-tablegen
Submodule tree-sitter-tablegen added at 568dd8
9 changes: 9 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ file-types = ["ll"]
comment-token = ";"
indent = { tab-width = 2, unit = " " }

[[language]]
name = "tablegen"
scope = "source.tablegen"
roots = []
file-types = ["td"]
comment-token = "//"
indent = { tab-width = 2, unit = " " }
injection-regex = "tablegen"

[[language]]
name = "markdown"
scope = "source.md"
Expand Down
90 changes: 90 additions & 0 deletions runtime/queries/tablegen/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[
(comment)
(multiline_comment)
] @comment

[
"("
")"
"["
"]"
"{"
"}"
"<"
">"
] @punctuation.bracket

[
","
";"
"."
] @punctuation.delimiter

[
"#"
"-"
"..."
":"
] @operator

[
"="
"!cond"
(operator_keyword)
] @function

[
"true"
"false"
] @constant.builtin.boolean

[
"?"
] @constant.builtin

(var) @variable

(template_arg (identifier) @variable.parameter)

(_ argument: (value (identifier) @variable.parameter))

(type) @type

"code" @type.builtin

(number) @constant.numeric.integer
[
(string_string)
(code_string)
] @string

(preprocessor) @keyword.directive

[
"class"
"field"
"let"
"defvar"
"def"
"defset"
"defvar"
"assert"
] @keyword

[
"let"
"in"
"foreach"
"if"
"then"
"else"
] @keyword.operator

"include" @keyword.control.import

[
"multiclass"
"defm"
] @namespace

(ERROR) @error
7 changes: 7 additions & 0 deletions runtime/queries/tablegen/indents.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
indent = [
"statement",
]

outdent = [
"}",
]
2 changes: 2 additions & 0 deletions runtime/queries/tablegen/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
([ (comment) (multiline_comment)] @injection.content
(#set! injection.language "comment"))
7 changes: 7 additions & 0 deletions runtime/queries/tablegen/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(class
body: (_) @class.inside) @class.around

(multiclass
body: (_) @class.inside) @class.around

(_ argument: _ @parameter.inside)