atom / language-python

Python package for Atom
Other
190 stars 146 forks source link

Implement naming conventions in Python grammar #313

Open chbk opened 4 years ago

chbk commented 4 years ago

Description of the Change

This is a rewrite of the Tree-sitter grammar to implement naming conventions for syntax scopes.

Benefits

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 commented 4 years ago

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())
chbk commented 3 years ago

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

jeff-hykin commented 3 years ago

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

chbk commented 3 years ago

Besides the screenshots above, what would you suggest?

ThatXliner commented 3 years ago

Can we merge this?

jeff-hykin commented 2 years ago

I think this is good to merge