diff options
| author | Amaan Qureshi <amaanq12@gmail.com> | 2023-03-16 07:00:30 -0400 |
|---|---|---|
| committer | Amaan Qureshi <amaanq12@gmail.com> | 2023-03-16 10:58:50 -0400 |
| commit | 17c275bfff86cfd4ac37a61a46bc8e4ade657e19 (patch) | |
| tree | d046818c08011780c302b5674a54a73eeb1d780a | |
| parent | feat(python): add "return" patterns to @indent_end (diff) | |
| download | nvim-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
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | lockfile.json | 3 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 8 | ||||
| -rw-r--r-- | queries/tablegen/folds.scm | 13 | ||||
| -rw-r--r-- | queries/tablegen/highlights.scm | 156 | ||||
| -rw-r--r-- | queries/tablegen/indents.scm | 27 | ||||
| -rw-r--r-- | queries/tablegen/injections.scm | 7 | ||||
| -rw-r--r-- | queries/tablegen/locals.scm | 51 |
8 files changed, 266 insertions, 0 deletions
@@ -325,6 +325,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [swift](https://github.com/alex-pinkus/tree-sitter-swift) (maintained by @alex-pinkus) - [x] [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) (maintained by @RaafatTurki) - [x] [t32](https://codeberg.org/xasc/tree-sitter-t32) (maintained by @xasc) +- [x] [tablegen](https://github.com/amaanq/tree-sitter-tablegen) (maintained by @amaanq) - [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce) - [x] [terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann) - [x] [thrift](https://github.com/duskmoon314/tree-sitter-thrift) (maintained by @amaanq, @duskmoon314) diff --git a/lockfile.json b/lockfile.json index 7d1774958..ccad247b0 100644 --- a/lockfile.json +++ b/lockfile.json @@ -455,6 +455,9 @@ "t32": { "revision": "f8106fcf5a27f905b3d9d55d9cd3e910bea70c60" }, + "tablegen": { + "revision": "e5e046e1b221e25111175469f02f3cf336010857" + }, "teal": { "revision": "2158ecce11ea542f9b791baf2c7fb33798174ed2" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 6a54c9032..89240ec8d 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1350,6 +1350,14 @@ list.t32 = { maintainers = { "@xasc" }, } +list.tablegen = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-tablegen", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + list.teal = { install_info = { url = "https://github.com/euclidianAce/tree-sitter-teal", 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) |
