Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Implement naming conventions in Ruby grammar #291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

chbk
Copy link
Contributor

@chbk chbk commented Jan 30, 2021

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

Related Pull Requests

@chbk
Copy link
Contributor Author

chbk commented Jan 30, 2021

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-ruby-0
Solarized Dark
solarized-dark-ruby-1
One Dark
one-dark-ruby-0
One Dark
one-dark-ruby-1
Base16 Tomorrow Dark
base16-dark-ruby-0
Base16 Tomorrow Dark
base16-dark-ruby-1
Atom Dark
atom-dark-ruby-0
Atom Dark
atom-dark-ruby-1
Solarized Light
solarized-light-ruby-0
Solarized Light
solarized-light-ruby-1
One Light
one-light-ruby-0
One Light
one-light-ruby-1
Base16 Tomorrow Light
base16-light-ruby-0
Base16 Tomorrow Light
base16-light-ruby-1
Atom Light
atom-light-ruby-0
Atom Light
atom-light-ruby-1

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

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

Successfully merging this pull request may close these issues.

1 participant