-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Basic Vlang Highlighter #7
base: master
Are you sure you want to change the base?
Changes from all commits
11878a8
6e84122
57081c8
8bb74e0
f05c8d9
0f81c86
c78c06a
4c35dd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## | ||
|
||
## v.kak by Conscat | ||
## | ||
|
||
# https://vlang.io | ||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | ||
|
||
# Detection | ||
# ‾‾‾‾‾‾‾‾‾ | ||
|
||
hook global BufCreate .+\.(v|vv|vsh) %{ | ||
set-option buffer filetype v | ||
} | ||
|
||
# Initialization | ||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | ||
|
||
hook global WinSetOption filetype=v %{ | ||
require-module v | ||
set-option window static_words %opt{v_static_words} | ||
add-highlighter window/v ref v | ||
} | ||
|
||
hook global WinSetOption filetype=(?!v).* %{ | ||
remove-highlighter window/v | ||
} | ||
|
||
declare-option str comment_line | ||
hook global BufSetOption filetype=v %{ | ||
set-option buffer comment_line '//' | ||
Cons-Cat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set-option buffer comment_block_begin '/*' | ||
set-option buffer comment_block_end '*/' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
} | ||
|
||
provide-module v %§ | ||
|
||
# Highlighters | ||
# ‾‾‾‾‾‾‾‾‾‾‾‾ | ||
|
||
add-highlighter shared/v regions | ||
add-highlighter shared/v/code default-region group | ||
|
||
add-highlighter shared/v/back_string region '`' '`' fill string | ||
add-highlighter shared/v/double_string region '"' (?<!\\)(\\\\)*" fill string | ||
add-highlighter shared/v/single_string region "'" (?<!\\)(\\\\)*' fill string | ||
add-highlighter shared/v/comment region -recurse /\* /\* \*/ fill comment | ||
add-highlighter shared/v/comment_line region '//' $ fill comment | ||
|
||
add-highlighter shared/v/code/ regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9_]+|0[xX][0-9a-fA-F]+)\.?([eE][+-]?[0-9]+)?\.*\b|(none|true|false)\b} 0:value | ||
|
||
add-highlighter shared/v/code/ regex (<|>|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:operator | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two pipe |
||
|
||
evaluate-commands %sh{ | ||
keywords='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' | ||
attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw required export if keep_args_alive unsafe' | ||
comptime='if else for' | ||
types='chan err i8 u8 byte i16 u16 int u32 i64 u64 f32 f64 ptr voidptr size_t map rune string bool' | ||
functions='print println eprint eprintln exit panic print_backtrace dump' | ||
|
||
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } | ||
|
||
# Add the language's grammar to the static completion list | ||
printf %s\\n "declare-option str-list v_static_words $(join "${keywords} ${attributes} ${comptime} ${types} ${functions}" ' ')" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to set the |
||
|
||
# Highlight keywords | ||
printf %s " | ||
add-highlighter shared/v/code/ regex (\b((?<![@])($(join "${keywords}" '|')))\b|(\[($(join "${attributes}" '|')([^\]|(^\n)]*))\])|([\$]($(join "${comptime}" '|')))(?:(?![\s+|\{|\}]))*) 0:keyword | ||
add-highlighter shared/v/code/ regex \b($(join "${types}" '|'))\b 0:type | ||
add-highlighter shared/v/code/ regex \b($(join "${functions}" '|'))\b 0:builtin | ||
" | ||
} | ||
|
||
§ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an empty line here :p