aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries
diff options
context:
space:
mode:
authorChris Dragan <chris@dragan.dev>2026-01-04 10:08:07 +0000
committerGitHub <noreply@github.com>2026-01-04 11:08:07 +0100
commit31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b (patch)
tree32249e8a96f55c0f9bad63e8d4712a08cb3f4034 /runtime/queries
parentfix(beancount): update to windows-compatible version (#8401) (diff)
downloadnvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.tar
nvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.tar.gz
nvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.tar.bz2
nvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.tar.lz
nvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.tar.xz
nvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.tar.zst
nvim-treesitter-31fc7e10cd7c1fd7717b439050d0f91c2c4f0a4b.zip
feat: add kos parser and queries (#8389)
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/kos/folds.scm19
-rw-r--r--runtime/queries/kos/highlights.scm141
-rw-r--r--runtime/queries/kos/injections.scm6
-rw-r--r--runtime/queries/kos/locals.scm41
4 files changed, 207 insertions, 0 deletions
diff --git a/runtime/queries/kos/folds.scm b/runtime/queries/kos/folds.scm
new file mode 100644
index 000000000..ca51a5406
--- /dev/null
+++ b/runtime/queries/kos/folds.scm
@@ -0,0 +1,19 @@
+[
+ (function_decl)
+ (constructor_literal)
+ (function_literal)
+ (class_decl)
+ (class_literal)
+ (do_statement)
+ (if_statement)
+ (try_statement)
+ (defer_statement)
+ (with_statement)
+ (switch_statement)
+ (switch_case)
+ (default_case)
+ (loop_statement)
+ (repeat_statement)
+ (while_statement)
+ (for_statement)
+] @fold
diff --git a/runtime/queries/kos/highlights.scm b/runtime/queries/kos/highlights.scm
new file mode 100644
index 000000000..0942b2b89
--- /dev/null
+++ b/runtime/queries/kos/highlights.scm
@@ -0,0 +1,141 @@
+(hash_bang) @keyword.directive
+
+(comment) @comment @spell
+
+(number) @number
+
+(identifier) @variable
+
+(property_identifier) @property
+
+[
+ (string_literal)
+ (string_literal_begin)
+ (string_literal_continuation)
+ (string_literal_end)
+] @string
+
+[
+ "case"
+ "default"
+ "else"
+ "if"
+ "switch"
+] @keyword.conditional
+
+"import" @keyword.import
+
+[
+ (break_statement)
+ (continue_statement)
+ "for"
+ "loop"
+ "repeat"
+ "while"
+] @keyword.repeat
+
+(for_statement
+ "in" @keyword.repeat)
+
+"class" @keyword.type
+
+[
+ "return"
+ "yield"
+] @keyword.return
+
+[
+ "catch"
+ "defer"
+ "throw"
+ "try"
+] @keyword.exception
+
+[
+ "constructor"
+ "fun"
+ "=>"
+] @keyword.function
+
+[
+ "_"
+ (line)
+ "assert"
+ ;"async"
+ "const"
+ "do"
+ "extends"
+ (fallthrough_statement)
+ ;"get"
+ ;"match"
+ "public"
+ ;"set"
+ ;"static"
+ "var"
+ "with"
+] @keyword
+
+[
+ (this)
+ (super)
+] @variable.builtin
+
+[
+ (false)
+ (true)
+] @boolean
+
+(void) @constant.builtin
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ ";"
+ ":"
+ "."
+ ","
+] @punctuation.delimiter
+
+[
+ (arithmetic_assignment_operator)
+ (comparison_operator)
+ (bitwise_operator)
+ (additive_operator)
+ (multiplicative_operator)
+ (logical_operator)
+ (unary_operator)
+ "->"
+ "..."
+ "="
+ "?"
+] @operator
+
+(conditional_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
+
+(class_member
+ (function_decl
+ name: (identifier) @function.method))
+
+(function_decl
+ name: (identifier) @function)
+
+(class_decl
+ name: (identifier) @type)
+
+(invocation
+ (identifier) @function.call)
+
+(invocation
+ (refinement
+ property: (property_identifier) @function.method.call))
diff --git a/runtime/queries/kos/injections.scm b/runtime/queries/kos/injections.scm
new file mode 100644
index 000000000..2677f272b
--- /dev/null
+++ b/runtime/queries/kos/injections.scm
@@ -0,0 +1,6 @@
+(((comment) @_jsdoc_comment
+ (#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
+ (#set! injection.language "jsdoc"))
+
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/kos/locals.scm b/runtime/queries/kos/locals.scm
new file mode 100644
index 000000000..37f14f4e6
--- /dev/null
+++ b/runtime/queries/kos/locals.scm
@@ -0,0 +1,41 @@
+; Scopes
+;-------
+(compound_statement) @local.scope
+
+(for_statement) @local.scope
+
+(function_decl) @local.scope
+
+(constructor_literal) @local.scope
+
+(function_literal) @local.scope
+
+(with_statement) @local.scope
+
+(catch_clause) @local.scope
+
+; Definitions
+;------------
+(variable_decl
+ variable: (identifier) @local.definition.var)
+
+(parameter
+ parameter: (identifier) @local.definition.parameter)
+
+(import
+ module: (identifier) @local.definition.import)
+
+(import
+ symbol: (identifier) @local.definition.import)
+
+(function_decl
+ name: (identifier) @local.definition.function
+ (#set! definition.var.scope parent))
+
+(class_decl
+ name: (identifier) @local.definition.type
+ (#set! definition.var.scope parent))
+
+; References
+;------------
+(identifier) @local.reference