-
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?
Conversation
I'd like to merge this, but if you have any more improvements to make to the PR, could you turn it into a draft and keep pushing commits? |
I don't know how to make the more advanced features yet. Since none of the other languages in this repo have similar hooks to go.kak, I assumed it would be fine to make a PR with only the syntax highlighting, and maybe add the indentation hooks later if I ever get around to figuring it out. Or I can draft this and work on that sooner, if they are important. |
I just fixed a few issues that I've recently noticed while using this. |
@@ -0,0 +1,74 @@ | |||
## | |||
|
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
hook global BufSetOption filetype=v %{ | ||
set-option buffer comment_line '//' | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Since comment.kak
might not be loaded and provide with these two options, they will also have to be declared. Maybe you could declare them within the hook too, since this scope is only used to add support for commenting.
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
There are two pipe |
signs following each other here.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You need to set the static_words
option directly, here.
I've created a highlighter for the V language. This is generally modeled after the Go highlighter, since V is largely modeled after Go. This uses the file extensions
.v
and.vsh
, the former of which conflicts with the built-in Verilog highlighter. Perhaps this should be moved into a different folder, so it doesn't get autoloaded? Or maybe Kakoune needs a more sophisticated language-detection feature.Unlike go.kak, this does not currently provide indentation hooks. There are also ways in which the highlighter could be more sophisticated. Certainly room for improvement in future commits, if this is merged.