language-ruby
language-ruby copied to clipboard
Implement naming conventions in Ruby grammar
Description of the Change
This is a rewrite of the Tree-sitter grammar to implement naming conventions for syntax scopes.
Benefits
- Many new scopes added to make the grammar explicit and exhaustive.
- Notable improvements on punctuation, keywords and support functions.
- Highlighting to be consistent with other languages.
Possible Drawbacks
Some new scopes to be added to themes. The changes aim to facilitate theme development, filling the template is enough to ensure coherent highlighting across languages, instead of painfully creating styling rules for every language separately.
Applicable Issues
- https://github.com/atom/atom/issues/8430
Related Pull Requests
- Naming conventions documentation
- Implementation in template theme
- Implementation in default syntax themes
- Implementation in C and C++ grammars
- Implementation in CSS grammar
- Implementation in Go grammar
- Implementation in HTML grammar
- Implementation in JavaScript and Regex grammars
- Implementation in Python grammar
Preview of the changes with Atom's default syntax themes:
| Without naming conventions (current Tree-sitter grammar) |
With naming conventions in theme and Tree-sitter grammar |
|---|---|
Solarized Dark![]() |
Solarized Dark![]() |
One Dark![]() |
One Dark![]() |
Base16 Tomorrow Dark![]() |
Base16 Tomorrow Dark![]() |
Atom Dark![]() |
Atom Dark![]() |
Solarized Light![]() |
Solarized Light![]() |
One Light![]() |
One Light![]() |
Base16 Tomorrow Light![]() |
Base16 Tomorrow Light![]() |
Atom Light![]() |
Atom Light![]() |
Code snippet:
require 'nebuchadnezzar.rb'
# That is the sound of inevitability
BEGIN {
call = ['Knock', 'Knock', 'Neo']
call.each do |x| puts x end
}
follow = /^(?:white)\s[rR]ab{2}it$/
door == 101 ? IO.open : IO.close
module Program
class Smith < Agent
include KungFu
def -@
super %(zion = #{23 << 1})
end
public
def capture(morpheus: nil)
if block_given?
yield self
else
@humans = virus | mammal
end
end
alias_method 'torment', :capture
end
end
$red_dress = Program::Smith.new
$red_dress&.torment(morpheus: true)
begin
6.times { *pills = :red, :blue }
rescue => unplug
PHONEBOOTH = {
'last_name': 'Anderson',
:first_name => 'Thomas'
}
end















