-
Notifications
You must be signed in to change notification settings - Fork 90
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
Distinction of end keywords #131
base: master
Are you sure you want to change the base?
Conversation
This looks promising! However, it makes the already rather complex grammar for Ruby even more complex. I’m not really sure if it’s really worth the cost. Maybe @infininight or @sorbits can have a look? |
If it can actually work, it might add some value to recognize these structures, but with trailing So at least I would like to see a test file for this PR, also, the commits should be squashed, we do not want to pull commits that are later followed by fixups, optimizations, typo fixes, etc. |
@sorbits sorry, but what is this test supposed to look like? Is it some kind of text file with various examples of ruby valid code containing these structures? |
+1 for this. Would help a lot in syntax highlighting. Currently it is not possible to highlight |
@noniq, @sorbits Hi, i think i resolved issues, and now it looks like if/unless/while/until works nice even after regex and division. Also i fixed |
@kiendang yes, it's not possible and thats why i started this PR. Unfortunately, it turned out to be harder than i thought. At this point i think i fixed all bugs which i knew. And it will be very helpful if you or anybody else could start using ruby bundle from this branch in order to find bugs |
Also I created a theme for textmate where module, class and def structures highlights with another color. It could help in testing. If one of these structures closing with red colored |
c426cd0
to
010b2fe
Compare
Commits has been squashed |
Split
You can check out test here - https://github.com/graceful-potato/test_ruby_grammars |
According to results of this benchmark i optimized complex regexes and get a pretty good improvement. I am pretty sure this benchmark is not ideal and for some reason first test always show slower result, but anyway it is better than nothing.
Update |
Fixed optimization. It slowed down performance a bit, but anyway it is faster then it was before
|
4786d96
to
89e1ecc
Compare
I've created a theme for vscode that uses this version of the grammar file. I hope it will help in testing. https://marketplace.visualstudio.com/items?itemName=GracefulPotato.gruvbox-ish |
eec4eca
to
ceea4ce
Compare
…begin, case and method definition. Equals sign in front of heredoc is no longer in the string.unquoted.heredoc.ruby scope. Fix highlighting for method parameters. Add support for multiline parameters.
ceea4ce
to
8d37e2c
Compare
Added meta scopes for every structure which closes with
end
so now it is possible to distinguishend
keyword betweenclass
,module
,def
,do
,if
,unless
,while
,until
,for
,begin
and highlight these structures differently.Move
rescue
andensure
to separate rules so it possible to highlight them depending on whether they are inside the block or inside the methodRemoved equals sign from the scope
string.unquoted.heredoc.ruby
in front of heredoc.