aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries
diff options
context:
space:
mode:
authorSebastian Neubauer2022-01-03 01:57:55 +0000
committerGitHub2022-01-03 01:57:55 +0000
commit8f2af713408b8b40cf71873bbc0ddc009a7b3da5 (patch)
tree68a0add35a49f2dd341f245a1ad06cbb06c29ec5 /runtime/queries
parent93a948d889f3d8fba97a37f163d080f9908dbaa3 (diff)
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>
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/tablegen/highlights.scm90
-rw-r--r--runtime/queries/tablegen/indents.toml7
-rw-r--r--runtime/queries/tablegen/injections.scm2
-rw-r--r--runtime/queries/tablegen/textobjects.scm7
4 files changed, 106 insertions, 0 deletions
diff --git a/runtime/queries/tablegen/highlights.scm b/runtime/queries/tablegen/highlights.scm
new file mode 100644
index 00000000..8ade5ba9
--- /dev/null
+++ b/runtime/queries/tablegen/highlights.scm
@@ -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
diff --git a/runtime/queries/tablegen/indents.toml b/runtime/queries/tablegen/indents.toml
new file mode 100644
index 00000000..43532f4d
--- /dev/null
+++ b/runtime/queries/tablegen/indents.toml
@@ -0,0 +1,7 @@
+indent = [
+ "statement",
+]
+
+outdent = [
+ "}",
+]
diff --git a/runtime/queries/tablegen/injections.scm b/runtime/queries/tablegen/injections.scm
new file mode 100644
index 00000000..0b476f86
--- /dev/null
+++ b/runtime/queries/tablegen/injections.scm
@@ -0,0 +1,2 @@
+([ (comment) (multiline_comment)] @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/tablegen/textobjects.scm b/runtime/queries/tablegen/textobjects.scm
new file mode 100644
index 00000000..2cb80268
--- /dev/null
+++ b/runtime/queries/tablegen/textobjects.scm
@@ -0,0 +1,7 @@
+(class
+ body: (_) @class.inside) @class.around
+
+(multiclass
+ body: (_) @class.inside) @class.around
+
+(_ argument: _ @parameter.inside)