Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Conversation

@graceful-potato
Copy link
Contributor

@graceful-potato graceful-potato commented Oct 13, 2020

Added ability to distinguish end keyword between class, module, def, do, if, unless, while, until, for, begin and highlight these structures differently.

Screenshot from 2020-04-09 17-00-41

Added new scopes:
keyword.control.class.begin.ruby for keyword class
keyword.control.class.end.ruby for keyword end which closes class
meta.class.ruby for everything between class and end

keyword.control.module.begin.ruby for keyword module
keyword.control.module.end.ruby for keyword end which closes module
meta.module.ruby for everything between module and end

keyword.control.for.begin.ruby for keyword for
keyword.control.for.end.ruby for keyword end which closes for loop
meta.block.for.ruby for everything between for and end

keyword.control.do.begin.ruby for keyword do
keyword.control.do.end.ruby for keyword end which closes do block
meta.block.do.ruby for everything between do and end

keyword.control.begin.begin.ruby for keyword begin
keyword.control.begin.end.ruby for keyword end which closes begin-end block
meta.block.begin.ruby for everything between begin and end

keyword.control.conditional.case.begin.ruby for keyword case
keyword.control.conditional.case.end.ruby for keyword end which closes case block
meta.block.case.ruby for everything between case and end

keyword.control.conditional.if.begin.ruby for keyword if (if block, not modifier)
keyword.control.conditional.if.end.ruby for keyword end which closes if block
meta.block.if.ruby for everything between if and end
keyword.control.modifier.conditional.if.ruby for if modifier (perform if condition)

keyword.control.conditional.unless.begin.ruby for keyword unless (unless block, not modifier)
keyword.control.conditional.unless.end.ruby for keyword end which closes unless block
meta.block.unless.ruby for everything between unless and end
keyword.control.modifier.conditional.unless.ruby for unless modifier (perform unless condition)

keyword.control.while.begin.ruby for keyword while (while block, not modifier)
keyword.control.while.end.ruby for keyword end which closes while block
meta.block.while.ruby for everything between while and end
keyword.control.modifier.while.ruby for while modifier (perform while condition)

keyword.control.until.begin.ruby for keyword until (until block, not modifier)
keyword.control.until.end.ruby for keyword end which closes until block
meta.block.until.ruby for everything between until and end
keyword.control.modifier.until.ruby for until modifier (perform until condition)

keyword.control.def.begin.ruby for keyword def
keyword.control.def.end.ruby for keyword end which closes method block
meta.function.method.with-arguments.ruby or meta.function.method.without-arguments.ruby for everything between def and end

keyword.control.rescue.ruby for keyword rescue
keyword.control.ensure.ruby for keyword ensure

keyword.control.conditional.else.ruby for keyword else
keyword.control.conditional.elsif.ruby for keyword elsif
keyword.control.conditional.when.ruby for keyword when
keyword.control.conditional.then.ruby for keyword then

keyword.control.BEGIN.ruby for keyword BEGIN
keyword.control.END.ruby for keyword END

keyword.control.optional.do.ruby for optional do like in for loop and while loop

punctuation.accessor.singleton.ruby for << in expressions like class << self

Each end keyword also has a scope keyword.control.end.ruby

  • The build passes
  • TSLint is mostly happy
  • Prettier has been run

@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #666 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #666   +/-   ##
======================================
  Coverage    5.08%   5.08%           
======================================
  Files          10      10           
  Lines         118     118           
  Branches       20      20           
======================================
  Hits            6       6           
  Misses        112     112           
Flag Coverage Δ
language_server_ruby 5.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2f901c...19ae425. Read the comment docs.

@graceful-potato
Copy link
Contributor Author

For testing you can install this theme
It will override your current ruby grammar file after installation and you can switch to your favorite theme back.

@wingrunr21
Copy link
Collaborator

@graceful-potato can you update this to account for your two other PRs that I merged?

@graceful-potato
Copy link
Contributor Author

@wingrunr21 ok, I will do it today.

@graceful-potato graceful-potato force-pushed the code-blocks-distinction branch from b5d4895 to a9e1145 Compare October 15, 2020 16:46
@graceful-potato
Copy link
Contributor Author

graceful-potato commented Oct 15, 2020

Wait, did I mess up with rebase somehow? I can see changes from #647 but these changes already in the master. I am confused. @wingrunr21


Update
I am not sure how and what did I do, but I believe I fixed it 😬

@graceful-potato graceful-potato force-pushed the code-blocks-distinction branch from a9e1145 to ed97a8d Compare October 15, 2020 17:15
@kylesnowschwartz
Copy link

This pull request is so exciting! Am I right in that it'll enable the development of going to matching end tags easily, such as in VSCodeVim/Vim#1885 ?

@graceful-potato
Copy link
Contributor Author

@kylesnowschwartz I am not sure about it. As far as i know its not so easy to get textmate scope from vscode extension. There is no API for that still.

@graceful-potato
Copy link
Contributor Author

@kylesnowschwartz the only way I found so far is to parse it again within extension, then you can get all scopes and found everything you want. I tried to fix #656 with this approach and I think it works fine. The only disadvantage is the need to parse the file twice.

@graceful-potato graceful-potato force-pushed the code-blocks-distinction branch 2 times, most recently from b349066 to 7170d6c Compare October 25, 2020 15:14
@graceful-potato graceful-potato force-pushed the code-blocks-distinction branch from 7170d6c to 19ae425 Compare October 31, 2020 00:18
@github-actions
Copy link

This PR has not had activity for 30 days. It will be automatically closed in 7 days.

@github-actions github-actions bot added the stale label Nov 30, 2020
@graceful-potato
Copy link
Contributor Author

Ping and quick update.
There will be 1 more way to define method in ruby3 called Endless method definition, so in order to correctly distinguish end keywords i need to treat this type of method definition separately.
I tried to quickly make a separate rule for this method, but turned out it is much more complicated than i thought.
It could be even impossible with this approach and looks like i need to rethink all rules related to methods.

@github-actions github-actions bot removed the stale label Dec 1, 2020
@github-actions
Copy link

This PR has not had activity for 30 days. It will be automatically closed in 7 days.

@github-actions github-actions bot added the stale label Dec 31, 2020
@github-actions github-actions bot closed this Jan 13, 2021
@graceful-potato
Copy link
Contributor Author

@wingrunr21 Hey there, I think i have a solution for endless methods.
Could you please reopen this PR if you are still intrested in this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants