Skip to content

Commit a4a2b50

Browse files
authored
Add support for KConfig (#14205)
1 parent e5d1f6c commit a4a2b50

File tree

7 files changed

+135
-0
lines changed

7 files changed

+135
-0
lines changed

book/src/generated/lang-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
| jsx |||||| `typescript-language-server` |
135135
| julia |||| | | `julia` |
136136
| just ||||| | `just-lsp` |
137+
| kconfig || || | | |
137138
| kdl |||| | | |
138139
| koka || || | | `koka` |
139140
| kotlin |||| | | `kotlin-language-server` |

languages.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4654,6 +4654,15 @@ name = "requirements"
46544654
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-requirements", rev = "caeb2ba854dea55931f76034978de1fd79362939" }
46554655

46564656
[[language]]
4657+
name = "kconfig"
4658+
file-types = ["kconfig", { glob = "kconfig.*" }]
4659+
scope = "source.kconfig"
4660+
4661+
[[grammar]]
4662+
name = "kconfig"
4663+
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-kconfig" , rev = "9ac99fe4c0c27a35dc6f757cef534c646e944881" }
4664+
4665+
[[language]]
46574666
name = "doxyfile"
46584667
scope = "source.doxyfile"
46594668
injection-regex = "[Dd]oxyfile"

runtime/queries/kconfig/folds.scm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
(config)
3+
(menuconfig)
4+
(choice)
5+
(comment_entry)
6+
(menu)
7+
(if)
8+
(help_text)
9+
] @fold
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[
2+
"source"
3+
"osource"
4+
"rsource"
5+
"orsource"
6+
] @keyword.control.import
7+
8+
[
9+
"mainmenu"
10+
"config"
11+
"configdefault"
12+
"menuconfig"
13+
"choice"
14+
"endchoice"
15+
"comment"
16+
"menu"
17+
"endmenu"
18+
"prompt"
19+
"default"
20+
"range"
21+
"help"
22+
(optional)
23+
(modules)
24+
] @keyword
25+
26+
[
27+
"if"
28+
"endif"
29+
"depends on"
30+
"select"
31+
"imply"
32+
"visible if"
33+
] @keyword.control.conditional
34+
35+
[
36+
"def_bool"
37+
"def_tristate"
38+
] @keyword.function
39+
40+
[
41+
"||"
42+
"&&"
43+
"="
44+
"!="
45+
"<"
46+
">"
47+
"<="
48+
">="
49+
"!"
50+
] @operator
51+
52+
[
53+
"bool"
54+
"tristate"
55+
"int"
56+
"hex"
57+
"string"
58+
] @type.builtin
59+
60+
[ "(" ")" ] @punctuation.bracket
61+
62+
(macro_variable ["$(" ")"] @punctuation.special)
63+
64+
(symbol) @variable
65+
66+
[
67+
(string)
68+
(macro_content)
69+
(text)
70+
] @string
71+
72+
(config name: (name (symbol) @constant))
73+
(configdefault name: (name (symbol) @constant))
74+
(menuconfig name: (name (symbol) @constant))
75+
(choice name: (name (symbol) @constant))
76+
77+
((symbol) @constant
78+
(#match? @constant "[A-Z0-9]+"))
79+
80+
(mainmenu name: (string) @markup.heading)
81+
(comment_entry name: (string) @markup.heading)
82+
(menu name: (string) @markup.heading)
83+
84+
(source (string) @string.special.url @string.special)
85+
86+
(comment) @comment
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(help_text (text) @align)
2+
3+
[
4+
(config)
5+
(menuconfig)
6+
(choice)
7+
(comment_entry)
8+
(menu)
9+
(if)
10+
(help_text)
11+
] @indent
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
((comment) @injection.content
2+
(#set! injection.language "comment"))

runtime/queries/kconfig/locals.scm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
(symbol)
3+
(string)
4+
] @local.reference
5+
6+
[
7+
(config)
8+
(menuconfig)
9+
(choice)
10+
(comment_entry)
11+
(menu)
12+
(if)
13+
] @local.scope
14+
15+
(type_definition (string) @local.definition.type)
16+
(type_definition (input_prompt (string) @local.definition.type))
17+
(type_definition_default (expression (string) @local.definition.type))

0 commit comments

Comments
 (0)