-
Notifications
You must be signed in to change notification settings - Fork 591
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
Annotation qualifier scope names #737
Comments
I personally think they should get the scopes they would in other parts of the syntax - if users/color scheme authors want, they can make the whole annotation the same color by utilizing the meta scope, while allowing others to have it presented in the same colors as they have come to expect from the main document. |
Quoting myself from the other issue, so that the discussion is in one place:
While it is certainly possible for color scheme authors to use the That's with an edited Material color scheme. At present, it's just inheriting scoping from |
It would look as much out of place as with just I posted an example of this in #704: |
@FichteFoll I think it looks more out of place than the equivalent simply because the syntax is driven by the token on the far left. Highlighting the meta scope obviously does fix the problem, but again, is that really what we want to encourage color scheme authors to do? |
No more out of place than a qualified function call, right? I personally think the leading punctuation will make the biggest difference. I also think that color schemes look better with accessors set to an opacity of something like 0.8. Perhaps that leading |
@djspiewak what is "the equivalent"? Note that the above screenshot was taken before any of the standardization has been implemented (which I am currently working on). |
That's wrong semantically, though. Ideally the color scheme should target Might be interesting to know which color schemes are used the most, so we can ensure that the largest user base will benefit from these decisions by us patching them upstream. |
Well, I am sort of asking here if it really is semantically wrong. If I thought it was totally wrong I wouldn't have suggested it. The |
@wbond I can't speak to the semantics in other languages, but for everything on the JVM (Java and Scala especially), annotations semantically work in the following way. The From that perspective, the following scoping would seem (mostly) right: @foo.bar.Baz
// ^ keyword.operator.annotation.scala
// ^^^^^^^^^^^ support.class.scala
// ^^^^^^^^^^^^ meta.annotation.scala But of course, no one thinks of it that way. Because the compiled results are placed in the bytecode, no one really thinks of This is why scoping the whole string ( @FichteFoll Here's a redone screenshot with a couple variants, vertically aligned (note that I still haven't modified my color scheme to do anything special with any of the annotation scopes): The parentheses have no impact. I just added them to demonstrate that the Scala mode doesn't use the |
I mentioned this on IRC too, but I wonder about whether or not The following tests should make this more clear: @ normal . decorator
# <- meta.annotation punctuation.definition.annotation
#^^^^^^^^^^^^^^^^^^^ meta.annotation
# ^^^^^^^^^^^^^^^^^^ meta.qualified-name
# ^^^^^^ meta.generic-name - variable.annotation
# ^^^^^^^^^ variable.annotation
# ^ punctuation.accessor.dot
class Class():
@functools.wraps(method, 12)# comment
#^^^ - meta.annotation
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.function
# ^ punctuation.definition.annotation
# ^^^^^^^^^^^^^^^ meta.qualified-name
# ^^^^^^^^^ meta.generic-name - variable.annotation
# ^ punctuation.accessor.dot
# ^^^^^ variable.annotation.function
# ^ punctuation.section.arguments.begin
# ^ punctuation.section.arguments.end
# ^^^^^^^^^ comment
def wrapper(self):
return self.__class__(method)
@deco #comment
#^^^ - meta.annotation
# ^^^^^^^^ comment
@deco[4]
# ^ invalid.illegal.character
@deco \
. rator
# ^^^^^^^ meta.annotation
# ^ punctuation.accessor.dot
@ deco \
. rator()
# ^^^^^^^ meta.annotation.function
# ^^^^^ meta.annotation.function variable.annotation.function
@ deco \
# ^^^^ meta.qualified-name meta.generic-name - variable.annotation
# ^ punctuation.separator.continuation.line |
Adheres to conventions discussed in sublimehq#709 and sublimehq#737.
From @FichteFoll:
I think the first and most important step is to clearly define the set of scopes and then care about color schemes. The other way round authors always try to hack their color schemes to provide the "best" look and feel with the set of available scopes for certain languages, which were not very consistent between the different languages in the past. Some color schemes implement special colors for single languages to provide best experience for JavaScript or HTML developement but looking ugly for others. This can be avoided by clearly defining and promoting language independed scopes, only. IMHO: Users will always use color schemes which provide best experience to them and I am quite sure popular color schemes will be updated somehow. Give evolution a chance ;-) |
As a conclusion from @djspiewak's description the whole @... stuff is just like a preprocessor definition in C or C++ und therefore should be treated like this. Means the different parts should get their own scopes but should not look like normal qualifiers. They should differ from normal code. I vote for @keith-hall: To quote from Sublime Text Documentation:
You should never ever encourage color scheme authors to create style definitions for meta-scopes. Even though I am not a friend of differen background colors for certain scopes, this might me the only valid exception for themed meta scopes. |
Maybe the exclusion of meta scopes for color highlighting is aging as well. Or at least for all meta scopes. For string interpolation, we started highlghting the entire construct as |
I don't want to hijack this issue but with a look on the python package I see As a result the whole content has a meta-scope and can have different color-scopes with string.quoted as a default. This is exactly correct and doesn't break the rule not to highlight meta-scopes from my perspective. This should keep the rule for meta in future I think. Clear rules are the base to automatically check color schemes and/or syntax definitions to ensure the least requirements are met. The only way a meta scope should be allowed to be used for coloring is to create a different set of colors for existing keywords. So an integer value can have a different accent color when used in a string then it has in normal code. This should be encouraged so the user can clearly identify it as part of a string or part of normal code. |
I personally think that either we give allowance for certain meta scopes to be targeted by color schemes (think JSON keys #421 (comment)) or we rethink our scoping strategy to introduce non-meta scopes that color schemes can optionally target. I do like your idea of automating color scheme conformance checks though, @deathaxe 👍 |
@keith-hall We basically have to give allowance for certain meta scopes to be targeted in some way, otherwise the proposed annotation scoping scheme simply doesn't work at all for color schemes that prefer to cover the entire thing. As an example: The above is impossible to achieve without targeting |
@djspiewak the |
A color definition could address The problems are with punctuations as they would need some kind of annotation specialization Using You are right, if you say the result is the same as coloring I vote for meta scopes being used for contextual reasons only as descriped in the current official Documentation. I just found the following good advice at the end of ST3's Documantation:
|
Nope. @scala.annotation.tailrec
// ^^^^^ - variable.annotation
// ^^^^^^^^^^ - variable.annotation |
I made my color scheme highlight |
@FichteFoll I think the objection I have is more that we're forced to target the |
@djspiewak I think the idea is that coloring the whole thing as one color is not the preferred way we are intending it to be used, instead we are intending for color schemes to color the individual parts. However, if someone wants to jam the square peg in the round hole, they certainly can. In some syntaxes, we have a If we are going to make further changes, I would think perhaps adding Either way, it is clear that there are two major ways that color scheme authors may want to style qualified identifiers in annotations, and baring a clear technically-superior choice, I think it'll come down to what I think we want the "default" to be. |
Here is my usecase, I know it's not common, but I thought it would be interesting to keep in mind, when thinking about what we want the user to be able to do. Since the new syntax definition has been added I customized my color scheme and the syntaxes I'm using the most to get something like: The main original point is that: the punctuation is matching the color of the related identifier. The parenthesis of a tuple doesn't receive the same color than parenthesis of a function call. I totally understand that not going to be the "default" but currently it's really complex to implement. To illustrate the complexity of writing correct color schemes, // Annotations
storage.modifier.annotation,
meta.statement.decorator meta.function-call,
meta.statement.decorator meta.function-call variable.function,
keyword.other.decorator,
variable.annotation,
{
foreground: $annotations;
fontStyle: bold;
meta.function-call.arguments,
{
foreground: $foreground;
fontStyle: none;
}
}
meta.statement.decorator meta.function-call meta.function-call.arguments variable.function
{
foreground: $function_call;
fontStyle: none;
}
punctuation.separator.annotation,
punctuation.section.annotation,
meta.statement.decorator meta.function-call punctuation.section.arguments,
meta.statement.decorator meta.function-call punctuation.separator.arguments,
{
foreground: $annotations;
}
meta.statement.decorator meta.function-call meta.function-call.arguments punctuation.section.arguments,
meta.statement.decorator meta.function-call meta.function-call.arguments punctuation.separator.arguments,
{
foreground: $function_call;
} Note that this is a feature that is only possible in ST, I don't know any other editor where you have such control over the syntaxes, (tm-language isn't powerful enough most of the time) and that easy to hack. This will make me stick with Sublime for a long time (even i f I have to fork syntaxes for all languages I use :-) ) Anyway, thanks to the ST team for the good work and for taking the time to think about this design issue and to ask the community, |
You can push two contexts with the lower context just providing a |
So I don't think we were ever able to come up with a plan for these. I made a comment at #1842 (comment) that is relevant, but would apply to more than just annotation qualifiers. |
Adheres to conventions discussed in sublimehq#709 and sublimehq#737.
With new guidelines for annotations in #709, we didn't address the issue of scoping identifier qualifiers, i.e. "paths". Example identifiers with qualifiers:
Python
Scalar
Java
My intention is to scope the final identifier as
variable.annotation
, with.
,::
, etc aspunctuation.accessor
and the@
(or other symbol) aspunctuation.definition.annotation
.The question raised in #735 is if the whole qualified identifier should get
variable.annotation
, or if classes/namespaces/modules should get scopes they would in other parts of the syntax. For instance something likesupport.class
in some cases.What do you think @djspiewak, @gwenzek, @FichteFoll, @keith-hall, @michaelblyons?
The text was updated successfully, but these errors were encountered: