aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDragonBillow <42114817+cathaysia@users.noreply.github.com>2024-04-28 16:26:39 +0800
committerGitHub <noreply@github.com>2024-04-28 04:26:39 -0400
commit37ac5f1f9f28af2e36f73e28a9ebac9490fcd731 (patch)
tree629a80348cd29b5c02523185b5af2132b9b8d6a2
parentbot(lockfile): update cuda, dtd, glsl, hlsl, koto, slang, wgsl_bevy, xml (diff)
downloadnvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.tar
nvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.tar.gz
nvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.tar.bz2
nvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.tar.lz
nvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.tar.xz
nvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.tar.zst
nvim-treesitter-37ac5f1f9f28af2e36f73e28a9ebac9490fcd731.zip
feat: add idl
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/idl/highlights.scm205
-rw-r--r--queries/idl/injections.scm8
4 files changed, 224 insertions, 0 deletions
diff --git a/lockfile.json b/lockfile.json
index e4d99e4d1..a01129a21 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -314,6 +314,9 @@
"hyprlang": {
"revision": "e5da7d0aa44403153e0394d87d9edea4e5bd6609"
},
+ "idl": {
+ "revision": "ea10c7b6c45d0a53e37afc54a825efe92d0b8f1e"
+ },
"ini": {
"revision": "bcb84a2d4bcd6f55b911c42deade75c8f90cb0c5"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index c6f169d63..ad8cbf904 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -949,6 +949,14 @@ list.hyprlang = {
maintainers = { "@luckasRanarison" },
}
+list.idl = {
+ install_info = {
+ url = "https://github.com/cathaysia/tree-sitter-idl",
+ files = { "src/parser.c" },
+ },
+ maintainers = { "@cathaysa" },
+}
+
list.ini = {
install_info = {
url = "https://github.com/justinmk/tree-sitter-ini",
diff --git a/queries/idl/highlights.scm b/queries/idl/highlights.scm
new file mode 100644
index 000000000..47ea00c25
--- /dev/null
+++ b/queries/idl/highlights.scm
@@ -0,0 +1,205 @@
+; https://neovim.io/doc/user/treesitter.html#treesitter-highlight-groups
+(comment) @comment @spell
+
+[
+ "enum"
+ "struct"
+ "union"
+ "bitmask"
+ "bitset"
+ "@annotation"
+ "interface"
+ "exception"
+ "typedef"
+] @keyword.type
+
+[
+ "module"
+ "attribute"
+] @keyword
+
+[
+ "const"
+ "readonly"
+] @keyword.modifier
+
+[
+ "switch"
+ "case"
+ "default"
+] @keyword.conditional
+
+[
+ "void"
+ (signed_short_int)
+ (signed_long_int)
+ (signed_longlong_int)
+ (unsigned_tiny_int)
+ (boolean_type)
+ (fixed_pt_const_type)
+ (octet_type)
+ (signed_tiny_int)
+ (unsigned_short_int)
+ (unsigned_long_int)
+ (unsigned_longlong_int)
+ (floating_pt_type)
+ (char_type)
+ (scoped_name)
+ (string_type)
+ (any_type)
+ (fixed_pt_type)
+ (sequence_type)
+ (map_type)
+] @type.builtin
+
+(boolean_literal) @boolean
+
+(number_literal) @number
+
+(char_literal) @character
+
+(string_literal) @string
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "<"
+ ">"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "-"
+ "*"
+ "+"
+ "="
+ "<<"
+ ">>"
+ "%"
+ "~"
+ "|"
+ "^"
+ "$"
+] @operator
+
+[
+ "::"
+ ";"
+ ":"
+ ","
+] @punctuation.delimiter
+
+(readonly_attr_declarator
+ (simple_declarator) @variable.member)
+
+(attr_declarator) @variable.member
+
+(annotation_appl
+ "@" @attribute
+ (scoped_name) @attribute)
+
+(op_dcl
+ (identifier) @function.method)
+
+(type_declarator
+ (simple_type_spec) @type
+ (any_declarators) @type)
+
+(param_dcl
+ (simple_declarator) @variable.parameter)
+
+(raises_expr
+ "raises" @keyword.exception
+ (scoped_name
+ (identifier) @type))
+
+(param_dcl
+ (param_attribute) @keyword.modifier)
+
+(preproc_call
+ directive: (preproc_directive) @keyword.directive
+ argument: (_) @constant)
+
+(module_dcl
+ (identifier) @module)
+
+(struct_def
+ (identifier) @type
+ parent: (scoped_name)? @type)
+
+(enum_dcl
+ (enumerator
+ (identifier) @constant))
+
+(annotation_dcl
+ (identifier) @type)
+
+(struct_forward_dcl
+ (identifier) @type)
+
+(bitmask_dcl
+ (identifier) @type)
+
+(bitset_dcl
+ (identifier) @type
+ (scoped_name)* @type)
+
+(enum_dcl
+ (identifier) @type)
+
+(union_forward_dcl
+ (identifier) @type)
+
+(interface_forward_dcl
+ (identifier) @type)
+
+(interface_header
+ (identifier) @type)
+
+(interface_inheritance_spec
+ (interface_name) @type)
+
+(union_def
+ (identifier) @type
+ (switch_type_spec) @type)
+
+(except_dcl
+ (identifier) @type)
+
+(annotation_member_type) @type
+
+(bitfield
+ (bitfield_spec
+ "bitfield" @keyword.modifier
+ (positive_int_const) @number
+ (destination_type)* @type)
+ (identifier) @variable.parameter)
+
+(bit_value) @constant
+
+(annotation_member
+ (annotation_member_type) @type
+ (simple_declarator) @property)
+
+(const_dcl
+ (const_type) @type
+ (identifier) @constant)
+
+(case_label
+ (const_expr) @constant)
+
+(simple_type_spec
+ (scoped_name
+ (identifier) @type))
+
+(simple_declarator
+ (identifier) @attribute)
+
+(array_declarator
+ (identifier) @attribute)
+
+(annotation_appl_param
+ (identifier) @attribute)
diff --git a/queries/idl/injections.scm b/queries/idl/injections.scm
new file mode 100644
index 000000000..e4a286e42
--- /dev/null
+++ b/queries/idl/injections.scm
@@ -0,0 +1,8 @@
+((comment) @injection.content
+ (#lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]")
+ (#set! injection.language "doxygen"))
+
+((comment) @injection.content
+ (#not-lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]")
+ (#not-lua-match? @injection.content "//@[a-zA-Z]")
+ (#set! injection.language "comment"))