aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/tablegen
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/tablegen
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/tablegen')
-rw-r--r--runtime/queries/tablegen/folds.scm13
-rw-r--r--runtime/queries/tablegen/highlights.scm159
-rw-r--r--runtime/queries/tablegen/indents.scm39
-rw-r--r--runtime/queries/tablegen/injections.scm9
-rw-r--r--runtime/queries/tablegen/locals.scm51
5 files changed, 271 insertions, 0 deletions
diff --git a/runtime/queries/tablegen/folds.scm b/runtime/queries/tablegen/folds.scm
new file mode 100644
index 000000000..0e95ca527
--- /dev/null
+++ b/runtime/queries/tablegen/folds.scm
@@ -0,0 +1,13 @@
+[
+ (assert)
+ (class)
+ (multiclass)
+ (def)
+ (defm)
+ (defset)
+ (defvar)
+ (foreach)
+ (if)
+ (let)
+ (value_suffix)
+] @fold
diff --git a/runtime/queries/tablegen/highlights.scm b/runtime/queries/tablegen/highlights.scm
new file mode 100644
index 000000000..c2f63b093
--- /dev/null
+++ b/runtime/queries/tablegen/highlights.scm
@@ -0,0 +1,159 @@
+; Preprocs
+(preprocessor_directive) @keyword.directive
+
+; Includes
+"include" @keyword.import
+
+; Keywords
+[
+ "assert"
+ "field"
+ "let"
+ "def"
+ "defm"
+ "defset"
+ "defvar"
+] @keyword
+
+[
+ "multiclass"
+ "class"
+] @keyword.type
+
+"in" @keyword.operator
+
+; Conditionals
+[
+ "if"
+ "else"
+ "then"
+] @keyword.conditional
+
+; Repeats
+"foreach" @keyword.repeat
+
+; Variables
+(identifier) @variable
+
+(var) @variable.builtin
+
+; Parameters
+(template_arg
+ (identifier) @variable.parameter)
+
+; Types
+(type) @type
+
+[
+ "bit"
+ "int"
+ "string"
+ "dag"
+ "bits"
+ "list"
+ "code"
+] @type.builtin
+
+(class
+ name: (identifier) @type)
+
+(multiclass
+ name: (identifier) @type)
+
+(def
+ name: (value
+ (_) @type))
+
+(defm
+ name: (value
+ (_) @type))
+
+(defset
+ name: (identifier) @type)
+
+(parent_class_list
+ (identifier) @type
+ (value
+ (_) @type)?)
+
+(anonymous_record
+ (identifier) @type)
+
+(anonymous_record
+ (value
+ (_) @type))
+
+((identifier) @type
+ (#lua-match? @type "^_*[A-Z][A-Z0-9_]+$"))
+
+; Fields
+(instruction
+ (identifier) @variable.member)
+
+(let_instruction
+ (identifier) @variable.member)
+
+; Functions
+([
+ (bang_operator)
+ (cond_operator)
+] @function
+ (#set! priority 105))
+
+; Operators
+[
+ "="
+ "#"
+ "-"
+ ":"
+ "..."
+] @operator
+
+; Literals
+(string) @string
+
+(code) @string.special
+
+(integer) @number
+
+(boolean) @boolean
+
+(uninitialized_value) @constant.builtin
+
+; Punctuation
+[
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "["
+ "]"
+] @punctuation.bracket
+
+[
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "<"
+ ">"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+ ";"
+] @punctuation.delimiter
+
+"!" @punctuation.special
+
+; Comments
+[
+ (comment)
+ (multiline_comment)
+] @comment @spell
+
+((comment) @keyword.directive @nospell
+ (#lua-match? @keyword.directive "^.*RUN"))
diff --git a/runtime/queries/tablegen/indents.scm b/runtime/queries/tablegen/indents.scm
new file mode 100644
index 000000000..16748edf1
--- /dev/null
+++ b/runtime/queries/tablegen/indents.scm
@@ -0,0 +1,39 @@
+[
+ (assert)
+ (class)
+ (multiclass)
+ (def)
+ (defm)
+ (defvar)
+ (foreach)
+ (if)
+ (let)
+ (value_suffix)
+] @indent.begin
+
+[
+ "}"
+ "]"
+ ")"
+ ">"
+] @indent.end
+
+[
+ "{"
+ "}"
+] @indent.branch
+
+[
+ "["
+ "]"
+] @indent.branch
+
+[
+ "("
+ ")"
+] @indent.branch
+
+[
+ "<"
+ ">"
+] @indent.branch
diff --git a/runtime/queries/tablegen/injections.scm b/runtime/queries/tablegen/injections.scm
new file mode 100644
index 000000000..99f7919b6
--- /dev/null
+++ b/runtime/queries/tablegen/injections.scm
@@ -0,0 +1,9 @@
+((code) @injection.content
+ (#set! injection.language "cpp")
+ (#offset! @injection.content 0 2 0 -2))
+
+((tablegen_file
+ (comment) @injection.content)
+ (#lua-match? @injection.content "^.*RUN")
+ (#set! injection.language "bash")
+ (#offset! @injection.content 0 8 0 0))
diff --git a/runtime/queries/tablegen/locals.scm b/runtime/queries/tablegen/locals.scm
new file mode 100644
index 000000000..c73100193
--- /dev/null
+++ b/runtime/queries/tablegen/locals.scm
@@ -0,0 +1,51 @@
+; Scopes
+[
+ (class)
+ (multiclass)
+ (def)
+ (defm)
+ (defset)
+ (defvar)
+ (foreach)
+ (if)
+ (let)
+] @local.scope
+
+; References
+[
+ (var)
+ (identifier)
+] @local.reference
+
+; Definitions
+(instruction
+ (identifier) @local.definition.field)
+
+(let_instruction
+ (identifier) @local.definition.field)
+
+(include_directive
+ (string) @local.definition.import)
+
+(template_arg
+ (identifier) @local.definition.parameter)
+
+(class
+ name: (identifier) @local.definition.type)
+
+(multiclass
+ name: (identifier) @local.definition.type)
+
+(def
+ name: (value
+ (_) @local.definition.type))
+
+(defm
+ name: (value
+ (_) @local.definition.type))
+
+(defset
+ name: (identifier) @local.definition.type)
+
+(def_var
+ name: (identifier) @local.definition.var)