Skip to content

Commit 5682776

Browse files
committed
feat: Add default configuration for KCL language server
1 parent 13b2dc3 commit 5682776

File tree

3 files changed

+179
-0
lines changed

3 files changed

+179
-0
lines changed

Diff for: book/src/generated/lang-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
| jsx |||| `typescript-language-server` |
120120
| julia |||| `julia` |
121121
| just |||| |
122+
| kcl | | | | `kcl-language-server` |
122123
| kdl |||| |
123124
| koka || || `koka` |
124125
| kotlin |||| `kotlin-language-server` |

Diff for: languages.toml

+12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jedi = { command = "jedi-language-server" }
5757
jq-lsp = { command = "jq-lsp" }
5858
jsonnet-language-server = { command = "jsonnet-language-server", args= ["-t", "--lint"] }
5959
julia = { command = "julia", timeout = 60, args = [ "--startup-file=no", "--history-file=no", "--quiet", "-e", "using LanguageServer; runserver()", ] }
60+
kcl-language-server = { command = "kcl-language-server" }
6061
koka = { command = "koka", args = ["--language-server", "--lsstdio"] }
6162
koto-ls = { command = "koto-ls" }
6263
kotlin-language-server = { command = "kotlin-language-server" }
@@ -4254,3 +4255,14 @@ indent = { tab-width = 2, unit = " " }
42544255
[[grammar]]
42554256
name = "werk"
42564257
source = { git = "https://github.com/little-bonsai/tree-sitter-werk", rev = "92b0f7fe98465c4c435794a58e961306193d1c1e" }
4258+
4259+
[[language]]
4260+
name = "kcl"
4261+
scope = "source.k"
4262+
file-types = ["kcl", { glob = "*.k" } ]
4263+
roots = ["kcl.mod", "kcl.yaml"]
4264+
language-servers = ["kcl-language-server"]
4265+
4266+
[[grammar]]
4267+
name = "kcl"
4268+
source = { git = "https://github.com/kcl-lang/tree-sitter-kcl", rev = "b0b2eb38009e04035a6e266c7e11e541f3caab7c" }

Diff for: runtime/queries/kcl/highlights.scm

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
(identifier) @variable
2+
3+
; Reset highlighting in string interpolations
4+
(interpolation) @none
5+
6+
(import_stmt
7+
(dotted_name
8+
(identifier) @namespace))
9+
10+
(import_stmt
11+
(dotted_name
12+
(identifier) @namespace)
13+
(identifier) @namespace)
14+
15+
(basic_type) @type
16+
17+
(schema_type
18+
(dotted_name
19+
(identifier) @type))
20+
21+
(schema_type
22+
(dotted_name
23+
(identifier) @namespace
24+
(identifier) @type))
25+
26+
(schema_expr
27+
(identifier) @type)
28+
29+
(protocol_stmt
30+
(identifier) @type)
31+
32+
(rule_stmt
33+
(identifier) @type)
34+
35+
(schema_stmt
36+
(identifier) @type)
37+
38+
(lambda_expr
39+
(typed_parameter (identifier) @parameter))
40+
41+
(lambda_expr
42+
(identifier) @parameter)
43+
44+
(selector_expr
45+
(select_suffix
46+
(identifier) @property))
47+
48+
(comment) @comment
49+
(string) @string
50+
(escape_sequence) @string.escape
51+
52+
(schema_stmt
53+
body: (block
54+
.
55+
(string
56+
(string_content) @string.documentation)))
57+
58+
(decorator
59+
(identifier) @attribute)
60+
61+
(call_expr
62+
function: (identifier) @function)
63+
64+
(call_expr
65+
function: (selector_expr
66+
(select_suffix
67+
(identifier) @function)))
68+
69+
[
70+
(integer)
71+
(float)
72+
] @number
73+
74+
[
75+
(true)
76+
(false)
77+
(none)
78+
(undefined)
79+
] @constant.builtin
80+
81+
[
82+
"all"
83+
"any"
84+
"assert"
85+
"as"
86+
"check"
87+
"elif"
88+
"else"
89+
"filter"
90+
"for"
91+
"if"
92+
"import"
93+
"lambda"
94+
"map"
95+
"mixin"
96+
"protocol"
97+
"rule"
98+
"schema"
99+
"type"
100+
] @keyword
101+
102+
[
103+
"("
104+
")"
105+
"["
106+
"]"
107+
"{"
108+
"}"
109+
] @punctuation.bracket
110+
111+
(interpolation
112+
"${" @punctuation.special
113+
"}" @punctuation.special)
114+
115+
[
116+
"+"
117+
"-"
118+
"*"
119+
"**"
120+
"/"
121+
"//"
122+
"%"
123+
"<<"
124+
">>"
125+
"&"
126+
"|"
127+
"^"
128+
"<"
129+
">"
130+
"~"
131+
"<="
132+
">="
133+
"=="
134+
"!="
135+
"@"
136+
"and"
137+
"or"
138+
"not"
139+
"in"
140+
"is"
141+
"="
142+
":"
143+
] @operator
144+
145+
; second argument is a regex in all regex functions with at least two arguments
146+
(call_expr
147+
function: (selector_expr
148+
(identifier) @_regex)
149+
arguments: (argument_list
150+
(_)
151+
.
152+
(string
153+
(string_content) @string.regexp))
154+
(#eq? @_regex "regex"))
155+
156+
; first argument is a regex in 'regex.compile' function
157+
(call_expr
158+
.
159+
function: (selector_expr
160+
(identifier) @_regex
161+
(select_suffix
162+
(identifier) @_fn (#eq? @_fn "compile")))
163+
arguments: (argument_list
164+
(string
165+
(string_content) @string.regexp))
166+
(#eq? @_regex "regex"))

0 commit comments

Comments
 (0)