Sublime-Instincts / BetterJinja

A Sublime Text package that provides enhanced syntax highlighting, completions, snippets & more for Jinja templates.
https://packagecontrol.io/packages/Jinja2
MIT License
15 stars 4 forks source link

[BUG] `in` in for..in incorrectly scoped as operator. #3

Closed ROpdebee closed 5 months ago

ROpdebee commented 4 years ago

Summary

The in in a for..in is scoped as an operator, while it's technically more of a keyword.

Expected Behaviour

   {% for user in users %}
##             ^^ text.html.basic meta.statement.jinja keyword.control.loop.for.in.jinja

Actual Behaviour

   {% for user in users %}
##             ^^ text.html.basic meta.statement.jinja keyword.operator.word.jinja

How to Reproduce

See above.

Problematic Jinja2 template.

{% for user in users %}
do something with {{user}}
{% endfor %}

Environment

[The environment you experienced this bug in.]

Additional context

N/A

UltraInstinct05 commented 4 years ago

Thanks. This is a mistake on my part. However, after going over a couple syntax definitions, I still not certain what third level scope name, it can be assigned to. (apart from the base keyword.control)

Some examples :-

  1. C# :- keyword.control.flow.cs
  2. Python :- keyword.control.flow.for.in.python
  3. Lua :- keyword.control.loop.lua

And I believe in all 3 of them, in has the same meaning, i.e. iterating over the elements of an iterable.

I guess I can assign it to keyword.control.flow.for.in.jinja though this can be discussed further.

ROpdebee commented 4 years ago

Since Jinja2 is inspired by the Python syntax, it makes sense to me to use the python one. Note however that the Python scopes have been updated in a newer build: https://github.com/sublimehq/Packages/commit/797164cbb4772ccf0d2af33fa05f63b014b44cea#diff-62db422a04a96e067da114ba6ed7d6e9R214 So I'd recommend using keyword.control.loop.for.in.jinja for consistency.

deathaxe commented 5 months ago

Scopes for keywords like as or in are not currently standardized or consistent across syntax definitions.

With a look at most common meanings keyword.operator is most suitable.