Skip to content

Commit 11878a8

Browse files
committed
Added Basic Vlang Highlighter
1 parent c6f8aac commit 11878a8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

rc/v.kak

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
##
2+
## v.kak by Conscat
3+
##
4+
5+
# https://vlang.io
6+
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
7+
8+
# Detection
9+
# ‾‾‾‾‾‾‾‾‾
10+
11+
hook global BufCreate .+\.(v|vsh) %{
12+
set-option buffer filetype v
13+
}
14+
15+
# Initialization
16+
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
17+
18+
hook global WinSetOption filetype=v %{
19+
require-module v
20+
add-highlighter window/v ref v
21+
}
22+
23+
hook global WinSetOption filetype=(?!v).* %{
24+
remove-highlighter window/v
25+
}
26+
27+
hook global BufSetOption filetype=v %{
28+
set-option buffer comment_line '//'
29+
}
30+
31+
provide-module v %§
32+
33+
# Highlighters
34+
# ‾‾‾‾‾‾‾‾‾‾‾‾
35+
36+
add-highlighter shared/v regions
37+
add-highlighter shared/v/code default-region group
38+
39+
add-highlighter shared/v/back_string region '`' '`' fill string
40+
add-highlighter shared/v/double_string region '"' (?<!\\)(\\\\)*" fill string
41+
add-highlighter shared/v/single_string region "'" (?<!\\)(\\\\)*' fill string
42+
add-highlighter shared/v/comment region -recurse /\* /\* \*/ fill comment
43+
add-highlighter shared/v/comment_line region '//' $ fill comment
44+
45+
add-highlighter shared/v/code/ regex (\b(if|as|asm|assert|atomic|break|const|continue|else|embed|enum|fn|for|go|import|in|interface|is|lock|match|module|mut|or|pub|return|rlock|select|shared|sizeof|static|struct|type|typeof|union|__offsetof|free|unsafe|strlen|strncmp|malloc|goto|defer)\b|\$(if|else|for)|\[(deprecated|inline|heap|manualfree|live|direct_array_access|typedef|windows_stdcall|console|json:|raw)([^\]|(^\n)]*)\]) 0:keyword
46+
47+
add-highlighter shared/v/code/ regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9_]+|0[xX][0-9a-fA-F]+)\.?([eE][+-]?[0-9]+)?\.*|none|true|false\b} 0:value
48+
add-highlighter shared/v/code/ regex \b(chan|err|i8|u8|byte|i16|u16|int|u32|i64|u64|f32|f64|ptr|voidptr|r|size_t|map|rune|string)\b 0:type
49+
50+
add-highlighter shared/v/code/ regex \b(print|println|eprint|eprintln|exit|panic|print_backtrace|dump|rmdir_all|mkdir|exec|ls|mv)\b 0:builtin
51+
52+
add-highlighter shared/v/code/ regex (<|>|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:operator
53+
54+
§

0 commit comments

Comments
 (0)