mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
feat: add kos parser and queries (#8389)
This commit is contained in:
parent
300b906a95
commit
31fc7e10cd
7 changed files with 365 additions and 0 deletions
19
runtime/queries/kos/folds.scm
Normal file
19
runtime/queries/kos/folds.scm
Normal file
|
|
@ -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
|
||||
141
runtime/queries/kos/highlights.scm
Normal file
141
runtime/queries/kos/highlights.scm
Normal file
|
|
@ -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))
|
||||
6
runtime/queries/kos/injections.scm
Normal file
6
runtime/queries/kos/injections.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(((comment) @_jsdoc_comment
|
||||
(#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
|
||||
(#set! injection.language "jsdoc"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
41
runtime/queries/kos/locals.scm
Normal file
41
runtime/queries/kos/locals.scm
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue