mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 01:10:02 -04:00
feat(kdl): parser and queries (#7657)
This commit is contained in:
parent
28f76678ca
commit
376a46ccec
5 changed files with 248 additions and 0 deletions
|
|
@ -410,6 +410,9 @@
|
||||||
"just": {
|
"just": {
|
||||||
"revision": "bb0c898a80644de438e6efe5d88d30bf092935cd"
|
"revision": "bb0c898a80644de438e6efe5d88d30bf092935cd"
|
||||||
},
|
},
|
||||||
|
"kcl": {
|
||||||
|
"revision": "b0b2eb38009e04035a6e266c7e11e541f3caab7c"
|
||||||
|
},
|
||||||
"kconfig": {
|
"kconfig": {
|
||||||
"revision": "9ac99fe4c0c27a35dc6f757cef534c646e944881"
|
"revision": "9ac99fe4c0c27a35dc6f757cef534c646e944881"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1211,6 +1211,14 @@ list.just = {
|
||||||
maintainers = { "@Hubro" },
|
maintainers = { "@Hubro" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.kcl = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/kcl-lang/tree-sitter-kcl",
|
||||||
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
|
},
|
||||||
|
maintainers = { "@bertbaron" },
|
||||||
|
}
|
||||||
|
|
||||||
list.kconfig = {
|
list.kconfig = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/amaanq/tree-sitter-kconfig",
|
url = "https://github.com/amaanq/tree-sitter-kconfig",
|
||||||
|
|
|
||||||
10
queries/kcl/folds.scm
Normal file
10
queries/kcl/folds.scm
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[
|
||||||
|
(protocol_stmt)
|
||||||
|
(rule_stmt)
|
||||||
|
(schema_stmt)
|
||||||
|
(check_stmt)
|
||||||
|
(if_stmt)
|
||||||
|
(lambda_expr)
|
||||||
|
(config_expr)
|
||||||
|
(string)
|
||||||
|
] @fold
|
||||||
201
queries/kcl/highlights.scm
Normal file
201
queries/kcl/highlights.scm
Normal file
|
|
@ -0,0 +1,201 @@
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
(import_stmt
|
||||||
|
(dotted_name
|
||||||
|
(identifier) @module))
|
||||||
|
|
||||||
|
(import_stmt
|
||||||
|
(dotted_name
|
||||||
|
(identifier) @module)
|
||||||
|
(identifier) @module)
|
||||||
|
|
||||||
|
(basic_type) @type.builtin
|
||||||
|
|
||||||
|
(schema_type
|
||||||
|
(dotted_name
|
||||||
|
(identifier) @type))
|
||||||
|
|
||||||
|
(schema_type
|
||||||
|
(dotted_name
|
||||||
|
(identifier) @module
|
||||||
|
(identifier) @type))
|
||||||
|
|
||||||
|
(schema_expr
|
||||||
|
(identifier) @type)
|
||||||
|
|
||||||
|
(protocol_stmt
|
||||||
|
(identifier) @type)
|
||||||
|
|
||||||
|
(rule_stmt
|
||||||
|
(identifier) @type)
|
||||||
|
|
||||||
|
(schema_stmt
|
||||||
|
(identifier) @type)
|
||||||
|
|
||||||
|
(lambda_expr
|
||||||
|
(typed_parameter
|
||||||
|
(identifier) @variable.parameter))
|
||||||
|
|
||||||
|
(lambda_expr
|
||||||
|
(identifier) @variable.parameter)
|
||||||
|
|
||||||
|
(selector_expr
|
||||||
|
(select_suffix
|
||||||
|
(identifier) @property))
|
||||||
|
|
||||||
|
(comment) @comment @spell
|
||||||
|
|
||||||
|
(string) @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
(schema_stmt
|
||||||
|
body: (block
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @string.documentation)))
|
||||||
|
|
||||||
|
(decorator
|
||||||
|
(identifier) @attribute)
|
||||||
|
|
||||||
|
(call_expr
|
||||||
|
function: (identifier) @function)
|
||||||
|
|
||||||
|
(call_expr
|
||||||
|
function: (selector_expr
|
||||||
|
(select_suffix
|
||||||
|
(identifier) @function)))
|
||||||
|
|
||||||
|
(integer) @number
|
||||||
|
|
||||||
|
(float) @number.float
|
||||||
|
|
||||||
|
[
|
||||||
|
(true)
|
||||||
|
(false)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
[
|
||||||
|
(none)
|
||||||
|
(undefined)
|
||||||
|
] @constant.builtin
|
||||||
|
|
||||||
|
"for" @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"elif"
|
||||||
|
"else"
|
||||||
|
"if"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
"lambda" @keyword.function
|
||||||
|
|
||||||
|
(quant_op) @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"protocol"
|
||||||
|
"rule"
|
||||||
|
"schema"
|
||||||
|
"type"
|
||||||
|
"mixin"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
"assert" @keyword.debug
|
||||||
|
|
||||||
|
[
|
||||||
|
"as"
|
||||||
|
"import"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
"check" @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
":"
|
||||||
|
"."
|
||||||
|
"?."
|
||||||
|
"?:"
|
||||||
|
"?"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
(interpolation
|
||||||
|
"${" @punctuation.special
|
||||||
|
"}" @punctuation.special)
|
||||||
|
|
||||||
|
[
|
||||||
|
"+"
|
||||||
|
"-"
|
||||||
|
"*"
|
||||||
|
"**"
|
||||||
|
"/"
|
||||||
|
"//"
|
||||||
|
"%"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"&"
|
||||||
|
"|"
|
||||||
|
"^"
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
"~"
|
||||||
|
"<="
|
||||||
|
">="
|
||||||
|
"=="
|
||||||
|
"!="
|
||||||
|
"="
|
||||||
|
"+="
|
||||||
|
"-="
|
||||||
|
"*="
|
||||||
|
"**="
|
||||||
|
"/="
|
||||||
|
"//="
|
||||||
|
"%="
|
||||||
|
"<<="
|
||||||
|
">>="
|
||||||
|
"&="
|
||||||
|
"^="
|
||||||
|
"->"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
"@" @attribute
|
||||||
|
|
||||||
|
[
|
||||||
|
"and"
|
||||||
|
"or"
|
||||||
|
"not"
|
||||||
|
"in"
|
||||||
|
"is"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
; second argument is a regex in all regex functions with at least two arguments
|
||||||
|
(call_expr
|
||||||
|
function: (selector_expr
|
||||||
|
(identifier) @_regex)
|
||||||
|
arguments: (argument_list
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @string.regexp))
|
||||||
|
(#eq? @_regex "regex"))
|
||||||
|
|
||||||
|
; first argument is a regex in 'regex.compile' function
|
||||||
|
(call_expr
|
||||||
|
function: (selector_expr
|
||||||
|
(identifier) @_regex
|
||||||
|
(select_suffix
|
||||||
|
(identifier) @_fn
|
||||||
|
(#eq? @_fn "compile")))
|
||||||
|
arguments: (argument_list
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @string.regexp))
|
||||||
|
(#eq? @_regex "regex"))
|
||||||
26
queries/kcl/injections.scm
Normal file
26
queries/kcl/injections.scm
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
(call_expr
|
||||||
|
function: (selector_expr
|
||||||
|
(identifier) @_regex)
|
||||||
|
arguments: (argument_list
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content))
|
||||||
|
(#eq? @_regex "regex")
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
(call_expr
|
||||||
|
function: (selector_expr
|
||||||
|
(identifier) @_regex
|
||||||
|
(select_suffix
|
||||||
|
(identifier) @_fn
|
||||||
|
(#eq? @_fn "compile")))
|
||||||
|
arguments: (argument_list
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content))
|
||||||
|
(#eq? @_regex "regex")
|
||||||
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue