Skip to content
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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Cons-Cat
Copy link

@Cons-Cat Cons-Cat commented Apr 28, 2021

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.

@lenormf
Copy link
Member

lenormf commented Apr 28, 2021

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?

rc/v.kak Show resolved Hide resolved
rc/v.kak Outdated Show resolved Hide resolved
rc/v.kak Outdated Show resolved Hide resolved
@Cons-Cat
Copy link
Author

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.

@Cons-Cat
Copy link
Author

Cons-Cat commented May 2, 2021

I just fixed a few issues that I've recently noticed while using this.

@Cons-Cat Cons-Cat requested a review from lenormf May 5, 2021 03:45
@@ -0,0 +1,74 @@
##

Copy link
Member

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 '*/'
Copy link
Member

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
Copy link
Member

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}" ' ')"
Copy link
Member

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.

@Cons-Cat Cons-Cat marked this pull request as draft May 7, 2021 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants