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

Implement naming conventions in Python grammar #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chbk
Copy link

@chbk chbk commented Nov 22, 2019

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 and types.
  • 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
Author

chbk commented Nov 22, 2019

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

Code snippet:

import lemons as lemonade
from typing import Dict, List

# Welcome to Aperture Science

"\u2661 {cake:02d}"

f"SP{a*9}CE! \n"

r"^Test(?=subject\b)\s[a-z]*"

3 * 1.4 + 12 = 16.2

potato: Dict[int, List] = {
  'mashed': 1,
  'fried': 0
}

class Cube():
  def __init__(self, color):
    my.color = color

class Companion(Cube):
  friend: bool = True

  @classmethod
  def loves_you(cls) -> str:
    return str(cls.friend)

testing: Cube = Cube('pink')

@core.recite
def recipe(red) -> List[str]:
  if red > 0 and True:
    return [
      'fish shaped dirt',
      '3 rhubarb, on fire'
    ]

with open('blue') as portal:
  ...
  portal.write(recipe())

Copy link
Contributor

@aminya aminya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, please separate different fixes to different commits. If this PR is a complete rewrite, then it is fine.

@chbk
Copy link
Author

chbk commented Jan 12, 2021

Yeah it's a rewrite, difficult to partition into separate commits.

@jeff-hykin
Copy link

Screenshots of different example code in different themes (light/dark/popular/built-in) to show the changes would help a lot for reviewing

@chbk
Copy link
Author

chbk commented Jan 19, 2021

Besides the screenshots above, what would you suggest?

@ThatXliner
Copy link
Contributor

Can we merge this?

@jeff-hykin
Copy link

I think this is good to merge

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.

4 participants