aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-08 14:18:25 +0000
committerBlaž Hrastnik2021-04-08 14:25:35 +0000
commit71c06c11cb2f3831326ec10035b66ac6df075c8a (patch)
tree96ae0b2a88a393bbbe75a2fc56ccb1aedb9a05d7 /runtime/queries
parent52da68e49a582f960ebf3ec26ae3279b102b01f2 (diff)
Import tree sitter queries.
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/c/highlights.scm81
-rw-r--r--runtime/queries/cpp/highlights.scm68
-rw-r--r--runtime/queries/rust/highlights.scm135
-rw-r--r--runtime/queries/rust/injections.scm9
4 files changed, 293 insertions, 0 deletions
diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm
new file mode 100644
index 00000000..04d9a04f
--- /dev/null
+++ b/runtime/queries/c/highlights.scm
@@ -0,0 +1,81 @@
+"break" @keyword
+"case" @keyword
+"const" @keyword
+"continue" @keyword
+"default" @keyword
+"do" @keyword
+"else" @keyword
+"enum" @keyword
+"extern" @keyword
+"for" @keyword
+"if" @keyword
+"inline" @keyword
+"return" @keyword
+"sizeof" @keyword
+"static" @keyword
+"struct" @keyword
+"switch" @keyword
+"typedef" @keyword
+"union" @keyword
+"volatile" @keyword
+"while" @keyword
+
+"#define" @keyword
+"#elif" @keyword
+"#else" @keyword
+"#endif" @keyword
+"#if" @keyword
+"#ifdef" @keyword
+"#ifndef" @keyword
+"#include" @keyword
+(preproc_directive) @keyword
+
+"--" @operator
+"-" @operator
+"-=" @operator
+"->" @operator
+"=" @operator
+"!=" @operator
+"*" @operator
+"&" @operator
+"&&" @operator
+"+" @operator
+"++" @operator
+"+=" @operator
+"<" @operator
+"==" @operator
+">" @operator
+"||" @operator
+
+"." @delimiter
+";" @delimiter
+
+(string_literal) @string
+(system_lib_string) @string
+
+(null) @constant
+(number_literal) @number
+(char_literal) @number
+
+(call_expression
+ function: (identifier) @function)
+(call_expression
+ function: (field_expression
+ field: (field_identifier) @function))
+(function_declarator
+ declarator: (identifier) @function)
+(preproc_function_def
+ name: (identifier) @function.special)
+
+(field_identifier) @property
+(statement_identifier) @label
+(type_identifier) @type
+(primitive_type) @type
+(sized_type_specifier) @type
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
+
+(identifier) @variable
+
+(comment) @comment
diff --git a/runtime/queries/cpp/highlights.scm b/runtime/queries/cpp/highlights.scm
new file mode 100644
index 00000000..3315fde0
--- /dev/null
+++ b/runtime/queries/cpp/highlights.scm
@@ -0,0 +1,68 @@
+; inherits: c
+
+; Functions
+
+(call_expression
+ function: (scoped_identifier
+ name: (identifier) @function))
+
+(template_function
+ name: (identifier) @function)
+
+(template_method
+ name: (field_identifier) @function)
+
+(template_function
+ name: (scoped_identifier
+ name: (identifier) @function))
+
+(function_declarator
+ declarator: (scoped_identifier
+ name: (identifier) @function))
+
+(function_declarator
+ declarator: (scoped_identifier
+ name: (identifier) @function))
+
+(function_declarator
+ declarator: (field_identifier) @function)
+
+; Types
+
+((namespace_identifier) @type
+ (#match? @type "^[A-Z]"))
+
+(auto) @type
+
+; Constants
+
+(this) @variable.builtin
+(nullptr) @constant
+
+; Keywords
+
+"catch" @keyword
+"class" @keyword
+"constexpr" @keyword
+"delete" @keyword
+"explicit" @keyword
+"final" @keyword
+"friend" @keyword
+"mutable" @keyword
+"namespace" @keyword
+"noexcept" @keyword
+"new" @keyword
+"override" @keyword
+"private" @keyword
+"protected" @keyword
+"public" @keyword
+"template" @keyword
+"throw" @keyword
+"try" @keyword
+"typename" @keyword
+"using" @keyword
+"virtual" @keyword
+
+; Strings
+
+(raw_string_literal) @string
diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm
new file mode 100644
index 00000000..196d483c
--- /dev/null
+++ b/runtime/queries/rust/highlights.scm
@@ -0,0 +1,135 @@
+; Identifier conventions
+
+; Assume all-caps names are constants
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
+
+; Assume that uppercase names in paths are types
+((scoped_identifier
+ path: (identifier) @type)
+ (#match? @type "^[A-Z]"))
+((scoped_identifier
+ path: (scoped_identifier
+ name: (identifier) @type))
+ (#match? @type "^[A-Z]"))
+
+; Assume other uppercase names are enum constructors
+((identifier) @constructor
+ (#match? @constructor "^[A-Z]"))
+
+; Function calls
+
+(call_expression
+ function: (identifier) @function)
+(call_expression
+ function: (field_expression
+ field: (field_identifier) @function.method))
+(call_expression
+ function: (scoped_identifier
+ "::"
+ name: (identifier) @function))
+
+(generic_function
+ function: (identifier) @function)
+(generic_function
+ function: (scoped_identifier
+ name: (identifier) @function))
+(generic_function
+ function: (field_expression
+ field: (field_identifier) @function.method))
+
+(macro_invocation
+ macro: (identifier) @function.macro
+ "!" @function.macro)
+
+; Function definitions
+
+(function_item (identifier) @function)
+(function_signature_item (identifier) @function)
+
+; Other identifiers
+
+(type_identifier) @type
+(primitive_type) @type.builtin
+(field_identifier) @property
+
+(line_comment) @comment
+(block_comment) @comment
+
+"(" @punctuation.bracket
+")" @punctuation.bracket
+"[" @punctuation.bracket
+"]" @punctuation.bracket
+
+(type_arguments
+ "<" @punctuation.bracket
+ ">" @punctuation.bracket)
+(type_parameters
+ "<" @punctuation.bracket
+ ">" @punctuation.bracket)
+
+"::" @punctuation.delimiter
+"." @punctuation.delimiter
+";" @punctuation.delimiter
+
+(parameter (identifier) @variable.parameter)
+
+(lifetime (identifier) @label)
+
+"break" @keyword
+"const" @keyword
+"continue" @keyword
+"default" @keyword
+"dyn" @keyword
+"else" @keyword
+"enum" @keyword
+"extern" @keyword
+"fn" @keyword
+"for" @keyword
+"if" @keyword
+"impl" @keyword
+"in" @keyword
+"let" @keyword
+"let" @keyword
+"loop" @keyword
+"macro_rules!" @keyword
+"match" @keyword
+"mod" @keyword
+"move" @keyword
+"pub" @keyword
+"ref" @keyword
+"return" @keyword
+"static" @keyword
+"struct" @keyword
+"trait" @keyword
+"type" @keyword
+"union" @keyword
+"unsafe" @keyword
+"use" @keyword
+"where" @keyword
+"while" @keyword
+(mutable_specifier) @keyword
+(use_list (self) @keyword)
+(scoped_use_list (self) @keyword)
+(scoped_identifier (self) @keyword)
+(super) @keyword
+
+(self) @variable.builtin
+
+(char_literal) @string
+(string_literal) @string
+(raw_string_literal) @string
+
+(boolean_literal) @constant.builtin
+(integer_literal) @constant.builtin
+(float_literal) @constant.builtin
+
+(escape_sequence) @escape
+
+(attribute_item) @attribute
+(inner_attribute_item) @attribute
+
+"as" @operator
+"*" @operator
+"&" @operator
+"'" @operator
diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm
new file mode 100644
index 00000000..6035d418
--- /dev/null
+++ b/runtime/queries/rust/injections.scm
@@ -0,0 +1,9 @@
+((macro_invocation
+ (token_tree) @injection.content)
+ (#set! injection.language "rust")
+ (#set! injection.include-children))
+
+((macro_rule
+ (token_tree) @injection.content)
+ (#set! injection.language "rust")
+ (#set! injection.include-children))