Skip to content

No scopes on periods #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chbk opened this issue Aug 9, 2017 · 17 comments
Closed

No scopes on periods #98

chbk opened this issue Aug 9, 2017 · 17 comments
Assignees

Comments

@chbk
Copy link
Contributor

chbk commented Aug 9, 2017

  • Editor name and version: Atom 1.18.0

  • Platform: macOS 10.12.6

  • Color scheme: custom

  • MagicPython version: 1.0.11

  • A sreenshot:
    p

  • 5-10 lines of surrounding code:

foo(fizz.buzz)              # period is meta.function-call.arguments.python

instance.method()           # period is not scoped

'string {}'.format(param)   # period is not scoped
@1st1
Copy link
Member

1st1 commented Aug 9, 2017

Why do you want them scoped? Does the built-in language-python scope periods?

@chbk
Copy link
Contributor Author

chbk commented Aug 9, 2017

It doesn't and I consider that a bug too. Other language packages scope periods. Also, braces and brackets are scoped, so periods should be too imo. I personally want them scoped as my syntax theme colors punctuation in white.

@1st1
Copy link
Member

1st1 commented Aug 9, 2017

Yeah, makes sense. We'll look into this. /cc @vpetrovykh

@vpetrovykh
Copy link
Member

The two of the more obvious choices for scope prefix are: punctuation (like the various brackets and parentheses) and keyword.operator (like the +). The purist in me wants to call it an operator, since that's what it actually is in Python, but the pragmatist suggests that calling . an operator may look terrible in many existing color schemes that highlight other operators (so I'd likely end up calling it something like punctuation.accessor.python).

If you have any thoughts or suggestions regarding the naming, please let me know here.

You can refer to scopes described here: https://manual.macromates.com/en/language_grammars. Historically, that's one of the descriptions of scopes that this grammar relied upon. If you know of a better document on scope name standards, please do provide a link.

@chbk
Copy link
Contributor Author

chbk commented Aug 9, 2017

Most packages scope them as punctuation.separator or punctuation.delimiter. The naming convention for Atom is here.

@vpetrovykh
Copy link
Member

Thanks for the link. I can see how punctuation.separator may be kind of reasonable for ..

@1st1
Copy link
Member

1st1 commented Aug 9, 2017

punctuation.separator is fine by me.

@1st1
Copy link
Member

1st1 commented Aug 10, 2017

We'll need to look how this change will look like with stock sublime and atom themes before making a decision through.

@1st1
Copy link
Member

1st1 commented Aug 10, 2017

Please research what other syntaxes use for periods, and how GitHub highlights periods for those languages. We don't want all . to be suddenly highlighted in red or blue on GitHub. All in all, we need to be extra careful with our choices here, as it may affect a huge number of people.

@chbk
Copy link
Contributor Author

chbk commented Aug 10, 2017

List of grammars used on GitHub.

List of languages sorted by popularity on GitHub:

@vpetrovykh
Copy link
Member

OK, let's go with punctuation.separator.period.python.

@1st1
Copy link
Member

1st1 commented Aug 10, 2017

@chbk Thanks a lot for the thorough research! We'll likely go with punctuation.separator.period.

@chbk
Copy link
Contributor Author

chbk commented Aug 10, 2017

Awesome 😄

@vpetrovykh
Copy link
Member

Incidentally, do you think that the scope of . in imports should be the same as everywhere else?

import foo.bar
from . import baz
from .spam import ham

@1st1
Copy link
Member

1st1 commented Aug 11, 2017

Yeah, why not.

@1st1
Copy link
Member

1st1 commented Aug 11, 2017

I've tested the updated grammar with all built-in Sublime Text themes, and built-in and top Atom themes. It seems that about 10% of colour schemas do highlight punctuation.separator.period.python scope differently from source.python, but none do it in a disturbing way.

@1st1
Copy link
Member

1st1 commented Aug 11, 2017

I've just released MagicPython 1.0.12 with this change in. Enjoy!

@1st1 1st1 closed this as completed Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants