language-python
language-python copied to clipboard
Implement naming conventions in Python 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 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
- 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 Ruby 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:
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())
Yeah it's a rewrite, difficult to partition into separate commits.
Screenshots of different example code in different themes (light/dark/popular/built-in) to show the changes would help a lot for reviewing
Besides the screenshots above, what would you suggest?
Can we merge this?
I think this is good to merge