hmatsuda / ruby-block

highlight matching ruby block on Atom editor
https://atom.io/packages/ruby-block
GNU General Public License v2.0
16 stars 11 forks source link

Highlighting does not work for grammar 'Ruby' files only 'Ruby on Rails' grammar #35

Open rogerprz opened 5 years ago

rogerprz commented 5 years ago

New to submitting bug issues, but wanted to see if anyone else was experiencing the same.

By default Atom detects my .rb file as grammar for 'Ruby' file. The highlighting wasn't working until I switched from 'Ruby' to 'Ruby on Rails'.

Request: Able to detect and use in multiple 'Ruby*' grammar detections by default or checkbox ability.

screen shot 2019-01-11 at 12 54 38 pm

kimbernator commented 5 years ago

I am seeing the same behavior.

kimbernator commented 5 years ago

It looks like the issue is a result of Tree-Sitter parsing. The quick fix for this is to uncheck "Use Tree Sitter Parsers" in the Atom settings menu.

When that setting is enabled, the function return in ruby-block.coffee takes place when this condition is checked:

return if cursor.getScopeDescriptor().scopes.indexOf(@rubyKeywordControlScope) is -1 when @rubyKeywordControlScope is set to 'keyword.control.ruby'

Rails is not using Tree-Sitter, so it uses a different layout for the array of scopes.

cursor.getScopeDescriptor().scopes in Ruby: Tree-Sitter Parsing off: ["source.ruby", "keyword.control.ruby"] Tree-Sitter Parsing on: ["source.ruby", "keyword.control"]

I made some quick adjustments to get the constructor name for the grammar object (TreeSitterGrammar vs. Grammar) and check the arrays appropriately, but that introduces other objects later in the code (tokenizeLine is not an available method anymore).

rogerprz commented 5 years ago

Great. That worked.

screen shot 2019-01-15 at 8 59 19 am
nickpresta commented 5 years ago

Is this an issue that is likely to be fixed in this project, or is this a problem with Tree Sitter parsers and we're waiting for an upstream fix?

LorinRicker commented 5 years ago

Not working for me: Atom v1.34.0 x64 on Ubuntu 18.04 Tried disabling the Tree Sitter Parsers as per above instructions, but no joy. Also tried switching grammar to Ruby on Rails. No highlighting or other good behavior observed in any of these settings.

atstockland commented 3 years ago

Sort of works for me. If I click on the block end it will highlight the bock beginning, but not the other way around. Not terribly helpful after I've already located the block end.

snackattas commented 3 years ago

It is kind of hidden, that, to get Ruby Block to work, you have to Uncheck "Use Tree Sitter Parsers"

Will there be any work to allow this package to work with "Use Tree Sitter Parsers" checked? Or, any communication to people downloading this package that they need to uncheck "Use Tree Sitter Parsers"?