aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/capnp
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/capnp
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/capnp')
-rw-r--r--runtime/queries/capnp/folds.scm14
-rw-r--r--runtime/queries/capnp/highlights.scm141
-rw-r--r--runtime/queries/capnp/indents.scm40
-rw-r--r--runtime/queries/capnp/injections.scm2
-rw-r--r--runtime/queries/capnp/locals.scm97
5 files changed, 294 insertions, 0 deletions
diff --git a/runtime/queries/capnp/folds.scm b/runtime/queries/capnp/folds.scm
new file mode 100644
index 000000000..6e3f9c187
--- /dev/null
+++ b/runtime/queries/capnp/folds.scm
@@ -0,0 +1,14 @@
+[
+ (annotation_targets)
+ (const_list)
+ (enum)
+ (interface)
+ (implicit_generics)
+ (generics)
+ (group)
+ (method_parameters)
+ (named_return_types)
+ (struct)
+ (struct_shorthand)
+ (union)
+] @fold
diff --git a/runtime/queries/capnp/highlights.scm b/runtime/queries/capnp/highlights.scm
new file mode 100644
index 000000000..a48c007ed
--- /dev/null
+++ b/runtime/queries/capnp/highlights.scm
@@ -0,0 +1,141 @@
+; Preproc
+[
+ (unique_id)
+ (top_level_annotation_body)
+] @keyword.directive
+
+; Includes
+[
+ "import"
+ "$import"
+ "embed"
+ "using"
+] @keyword.import
+
+(import_path) @string.special.path
+
+; Keywords
+"extends" @keyword
+
+[
+ "struct"
+ "interface"
+ "union"
+ "enum"
+ "annotation"
+ "group"
+ "namespace"
+] @keyword.type
+
+; Builtins
+"const" @keyword.modifier
+
+[
+ (primitive_type)
+ "List"
+] @type.builtin
+
+; Typedefs
+(type_definition) @type.definition
+
+; Labels (@number, @number!)
+(field_version) @label
+
+; Methods
+[
+ (annotation_definition_identifier)
+ (method_identifier)
+] @function.method
+
+; Fields
+(field_identifier) @variable.member
+
+; Properties
+(property) @property
+
+; Parameters
+[
+ (param_identifier)
+ (return_identifier)
+] @variable.parameter
+
+(annotation_target) @variable.parameter.builtin
+
+; Constants
+[
+ (const_identifier)
+ (local_const)
+ (enum_member)
+] @constant
+
+(void) @constant.builtin
+
+; Types
+[
+ (enum_identifier)
+ (extend_type)
+ (type_identifier)
+] @type
+
+; Attributes
+[
+ (annotation_identifier)
+ (attribute)
+] @attribute
+
+; Operators
+"=" @operator
+
+; Literals
+[
+ (string)
+ (concatenated_string)
+ (block_text)
+ (namespace)
+] @string
+
+(namespace) @string.special
+
+(escape_sequence) @string.escape
+
+(data_string) @string.special
+
+(number) @number
+
+(float) @number.float
+
+(boolean) @boolean
+
+(data_hex) @string.special.symbol
+
+; Punctuation
+[
+ "*"
+ "$"
+ ":"
+] @punctuation.special
+
+[
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "["
+ "]"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+ ";"
+ "->"
+] @punctuation.delimiter
+
+; Comments
+(comment) @comment @spell
diff --git a/runtime/queries/capnp/indents.scm b/runtime/queries/capnp/indents.scm
new file mode 100644
index 000000000..cc2f4d756
--- /dev/null
+++ b/runtime/queries/capnp/indents.scm
@@ -0,0 +1,40 @@
+[
+ (annotation_targets)
+ (const)
+ (enum)
+ (interface)
+ (implicit_generics)
+ (generics)
+ (group)
+ (method_parameters)
+ (named_return_types)
+ (struct)
+ (union)
+ (field)
+] @indent.begin
+
+((struct_shorthand
+ (property)) @indent.align
+ (#set! indent.open_delimiter "(")
+ (#set! indent.close_delimiter ")"))
+
+((method
+ (field_version)) @indent.align
+ (#set! indent.open_delimiter field_version))
+
+((const_list
+ (const_value)) @indent.align
+ (#set! indent.open_delimiter "[")
+ (#set! indent.close_delimiter "]"))
+
+(concatenated_string) @indent.align
+
+[
+ "}"
+ ")"
+] @indent.end @indent.branch
+
+[
+ (ERROR)
+ (comment)
+] @indent.auto
diff --git a/runtime/queries/capnp/injections.scm b/runtime/queries/capnp/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/runtime/queries/capnp/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/capnp/locals.scm b/runtime/queries/capnp/locals.scm
new file mode 100644
index 000000000..d1f0ccacc
--- /dev/null
+++ b/runtime/queries/capnp/locals.scm
@@ -0,0 +1,97 @@
+[
+ (message)
+ (annotation_targets)
+ (const_list)
+ (enum)
+ (interface)
+ (implicit_generics)
+ (generics)
+ (group)
+ (method_parameters)
+ (named_return_types)
+ (struct)
+ (struct_shorthand)
+ (union)
+] @local.scope
+
+[
+ (extend_type)
+ (field_type)
+] @local.reference
+
+(custom_type
+ (type_identifier) @local.reference)
+
+(custom_type
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.reference)))
+
+(annotation_definition_identifier) @local.definition
+
+(const_identifier) @local.definition.constant
+
+(enum
+ (enum_identifier) @local.definition.enum)
+
+[
+ (enum_member)
+ (field_identifier)
+] @local.definition.field
+
+(method_identifier) @local.definition.method
+
+(namespace) @local.definition.namespace
+
+[
+ (param_identifier)
+ (return_identifier)
+] @local.definition.parameter
+
+(group
+ (type_identifier) @local.definition.type)
+
+(struct
+ (type_identifier) @local.definition.type)
+
+(union
+ (type_identifier) @local.definition.type)
+
+(interface
+ (type_identifier) @local.definition.type)
+
+; Generics Related (don't know how to combine these)
+(struct
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.definition.parameter)))
+
+(interface
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.definition.parameter)))
+
+(method
+ (implicit_generics
+ (implicit_generic_parameters
+ (generic_identifier) @local.definition.parameter)))
+
+(method
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.definition.parameter)))
+
+(annotation
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.definition.type)))
+
+(replace_using
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.definition.type)))
+
+(return_type
+ (generics
+ (generic_parameters
+ (generic_identifier) @local.definition.type)))