aboutsummaryrefslogtreecommitdiffstats
path: root/queries
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-03-16 07:00:30 -0400
committerAmaan Qureshi <amaanq12@gmail.com>2023-03-16 10:58:50 -0400
commit17c275bfff86cfd4ac37a61a46bc8e4ade657e19 (patch)
treed046818c08011780c302b5674a54a73eeb1d780a /queries
parentfeat(python): add "return" patterns to @indent_end (diff)
downloadnvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.tar
nvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.tar.gz
nvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.tar.bz2
nvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.tar.lz
nvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.tar.xz
nvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.tar.zst
nvim-treesitter-17c275bfff86cfd4ac37a61a46bc8e4ade657e19.zip
feat: add LLVM TableGen
Diffstat (limited to 'queries')
-rw-r--r--queries/tablegen/folds.scm13
-rw-r--r--queries/tablegen/highlights.scm156
-rw-r--r--queries/tablegen/indents.scm27
-rw-r--r--queries/tablegen/injections.scm7
-rw-r--r--queries/tablegen/locals.scm51
5 files changed, 254 insertions, 0 deletions
diff --git a/queries/tablegen/folds.scm b/queries/tablegen/folds.scm
new file mode 100644
index 000000000..a1727b151
--- /dev/null
+++ b/queries/tablegen/folds.scm
@@ -0,0 +1,13 @@
+[
+ (assert)
+ (class)
+ (multiclass)
+ (def)
+ (defm)
+ (defset)
+ (defvar)
+ (foreach)
+ (if)
+ (let)
+ (value_suffix)
+] @fold
diff --git a/queries/tablegen/highlights.scm b/queries/tablegen/highlights.scm
new file mode 100644
index 000000000..b0b4b000c
--- /dev/null
+++ b/queries/tablegen/highlights.scm
@@ -0,0 +1,156 @@
+; Preprocs
+
+(preprocessor_directive) @preproc
+
+; Includes
+
+"include" @include
+
+; Keywords
+
+[
+ "assert"
+ "class"
+ "multiclass"
+ "field"
+ "let"
+ "def"
+ "defm"
+ "defset"
+ "defvar"
+] @keyword
+
+[
+ "in"
+] @keyword.operator
+
+; Conditionals
+
+[
+ "if"
+ "else"
+ "then"
+] @conditional
+
+; Repeats
+
+[
+ "foreach"
+] @repeat
+
+; Variables
+
+(identifier) @variable
+
+(var) @variable.builtin
+
+; Parameters
+
+(template_arg (identifier) @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) @field)
+
+(let_instruction
+ (identifier) @field)
+
+; 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) @preproc
+ (#lua-match? @preproc "^.*RUN"))
+
+; Errors
+
+(ERROR) @error
diff --git a/queries/tablegen/indents.scm b/queries/tablegen/indents.scm
new file mode 100644
index 000000000..74287b02f
--- /dev/null
+++ b/queries/tablegen/indents.scm
@@ -0,0 +1,27 @@
+[
+ (assert)
+ (class)
+ (multiclass)
+ (def)
+ (defm)
+ (defvar)
+ (foreach)
+ (if)
+ (let)
+ (value_suffix)
+] @indent
+
+[
+ "}"
+ "]"
+ ")"
+ ">"
+] @indent_end
+
+[ "{" "}" ] @branch
+
+[ "[" "]" ] @branch
+
+[ "(" ")" ] @branch
+
+[ "<" ">" ] @branch
diff --git a/queries/tablegen/injections.scm b/queries/tablegen/injections.scm
new file mode 100644
index 000000000..b137e472c
--- /dev/null
+++ b/queries/tablegen/injections.scm
@@ -0,0 +1,7 @@
+((code) @cpp
+ (#offset! @cpp 0 2 0 -2))
+
+((tablegen_file
+ (comment) @bash)
+ (#lua-match? @bash "^.*RUN")
+ (#offset! @bash 0 8))
diff --git a/queries/tablegen/locals.scm b/queries/tablegen/locals.scm
new file mode 100644
index 000000000..04602991c
--- /dev/null
+++ b/queries/tablegen/locals.scm
@@ -0,0 +1,51 @@
+; Scopes
+
+[
+ (class)
+ (multiclass)
+ (def)
+ (defm)
+ (defset)
+ (defvar)
+ (foreach)
+ (if)
+ (let)
+] @scope
+
+; References
+
+[
+ (var)
+ (identifier)
+] @reference
+
+; Definitions
+
+(instruction
+ (identifier) @definition.field)
+
+(let_instruction
+ (identifier) @definition.field)
+
+(include_directive
+ (string) @definition.import)
+
+(template_arg (identifier) @definition.parameter)
+
+(class
+ name: (identifier) @definition.type)
+
+(multiclass
+ name: (identifier) @definition.type)
+
+(def
+ name: (value (_) @definition.type))
+
+(defm
+ name: (value (_) @definition.type))
+
+(defset
+ name: (identifier) @definition.type)
+
+(def_var
+ name: (identifier) @definition.var)