Skip to content

Commit 1b1a788

Browse files
committed
Ticket #5003: add syntax highlighting for Kconfig
* Implement Kconfig specification with Kconfiglib extensions. * Highlight the following files: - Kconfig / Kconfig.* - for Linux kernel, U-Boot, Zephyr. - Config.in / Config.in.* / Config.src - for Buildroot, Busybox. - *.kconf / *.kconfig - just alternative extension-based variant. Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
1 parent 7abc9ea commit 1b1a788

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

misc/syntax/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ SYNTAXFILES = \
5050
java.syntax \
5151
js.syntax \
5252
json.syntax \
53+
kconfig.syntax \
5354
kotlin.syntax \
5455
latex.syntax \
5556
lisp.syntax \

misc/syntax/Syntax.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,5 +366,8 @@ include caddyfile.syntax
366366
file Dockerfile.\*$ Dockerfile
367367
include dockerfile.syntax
368368

369+
file (/Kconfig(\\.[A-z0-9-]\+)\*|/Config\\.(in|src)(\\.[A-z0-9-]\+)\*|.\*\\.kconf(ig)?)$ Kconfig
370+
include kconfig.syntax
371+
369372
file .\* unknown
370373
include unknown.syntax

misc/syntax/kconfig.syntax

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Kconfig syntax
2+
#
3+
# Specifications:
4+
# https://docs.kernel.org/kbuild/kconfig-language.html
5+
# https://github.com/ulfalizer/Kconfiglib?tab=readme-ov-file#kconfig-extensions
6+
7+
define kword yellow
8+
define type brightmagenta
9+
define property brightmagenta
10+
define condition yellow
11+
define operator brightcyan
12+
define brace brightcyan
13+
define number cyan
14+
define string green
15+
define escape brightgreen
16+
define comment brown
17+
18+
context default
19+
keyword whole linestart \[\t\s\]config kword
20+
keyword whole linestart \[\t\s\]menuconfig kword
21+
keyword whole linestart \[\t\s\]menu kword
22+
keyword whole linestart \[\t\s\]endmenu kword
23+
keyword whole linestart \[\t\s\]mainmenu kword
24+
keyword whole linestart \[\t\s\]choice kword
25+
keyword whole linestart \[\t\s\]endchoice kword
26+
keyword whole linestart \[\t\s\]comment kword
27+
keyword whole linestart \[\t\s\]source kword
28+
keyword whole linestart \[\t\s\]osource kword
29+
keyword whole linestart \[\t\s\]rsource kword
30+
keyword whole linestart \[\t\s\]orsource kword
31+
32+
keyword whole if condition
33+
keyword whole linestart \[\t\s\]endif condition
34+
35+
keyword whole linestart \[\t\s\]bool type
36+
keyword whole linestart \[\t\s\]tristate type
37+
keyword whole linestart \[\t\s\]string type
38+
keyword whole linestart \[\t\s\]hex type
39+
keyword whole linestart \[\t\s\]int type
40+
41+
keyword whole linestart \[\t\s\]def_bool type
42+
keyword whole linestart \[\t\s\]def_tristate type
43+
keyword whole linestart \[\t\s\]def_string type
44+
keyword whole linestart \[\t\s\]def_hex type
45+
keyword whole linestart \[\t\s\]def_int type
46+
47+
keyword whole linestart \[\t\s\]prompt property
48+
keyword whole linestart \[\t\s\]default property
49+
keyword whole linestart \[\t\s\]depends\son property
50+
keyword whole linestart \[\t\s\]select property
51+
keyword whole linestart \[\t\s\]imply property
52+
keyword whole linestart \[\t\s\]transitional property
53+
keyword whole linestart \[\t\s\]visible\sif property
54+
keyword whole linestart \[\t\s\]range property
55+
keyword whole linestart \[\t\s\]option property
56+
keyword whole linestart \[\t\s\]optional property
57+
keyword whole linestart \[\t\s\]help property
58+
keyword whole linestart \[\t\s\]---help--- property
59+
60+
keyword = operator
61+
keyword > operator
62+
keyword < operator
63+
keyword >= operator
64+
keyword <= operator
65+
keyword || operator
66+
keyword && operator
67+
keyword ! operator
68+
69+
keyword ( brace
70+
keyword ) brace
71+
72+
keyword whole 0x\{0123456789ABCDEFabcdef\}\[0123456789ABCDEFabcdef\] number
73+
keyword whole \{0123456789\}\[0123456789\] number
74+
75+
# sometimes quotes are escaped in help like \"foo\" => do not start string context
76+
keyword \\"
77+
78+
context # \n comment
79+
spellcheck
80+
81+
context " " string
82+
keyword \\" escape
83+
keyword \\\\ escape

0 commit comments

Comments
 (0)