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

Add highlighting for variables #106

Open
LoadingBG opened this issue Oct 10, 2020 · 4 comments
Open

Add highlighting for variables #106

LoadingBG opened this issue Oct 10, 2020 · 4 comments

Comments

@LoadingBG
Copy link

LoadingBG commented Oct 10, 2020

The problem I have with the highlighting is that variables blend with the code:

puts arr

is just one color - grey, which can be confusing:

puts cr # How it looks in neovim - same color

Also variables within anonymous functions are colored just when they're defined:

10.times { |x| puts x }

only the x between the pipes is colored while the second use of x is not.
Here's a picture of a test program and the highlighting I have.

@jlcrochet
Copy link
Contributor

Local variables aren't highlighted by default because some people don't like them to be; however, they are matched as crystalLocalVariableOrMethod, so you can try :hi! link crystalLocalVariableOrMethod Identifier or something similar based on your preferences.

@LoadingBG
Copy link
Author

The command doesn't work for me.

@jlcrochet
Copy link
Contributor

You're right, I forgot that crystalLocalVariableOrMethod is transparent.

@rhysd
Copy link
Member

rhysd commented Oct 12, 2020

I think highlighting variables perfectly is not possible with highlighting system of Vim/Neovim. Since it requires Crystal parser. Until parsing the source into Crystal abstract syntax tree, it cannot be determined that the identifier is variable or not. Neovim's tree-sitter support may change the situation in the future, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants