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
Highlight @available/#available attributes #56
Conversation
This adds the new (introduced in Swift 2) @available and #available attributes to the swift syntax file. Resolves #54
I think that the text within the parenthesis should be un-highlighted. |
@aclissold I do, however, Xcode highlights the 9.0. I wonder if you can un-highlight inside the brackets. I'm not too familiar with vim syntax highlighting. EDIT: I should also mention that I override some of the syntax defaults of this plugin, one of which is to link the Operator with Normal (as it should be 😛), so it looks the same for me as it does in Xcode. |
Oh! Well if that's how Xcode does it… :P As for And, maybe And and, it looks like the line control statement |
Yep, I agree with your comments, I'll pick swiftConditionStatement for it then. 😄 About |
Conforming to Xcode, the syntax file now highlights platforms contained within the `#available` condition. It also now removes highlighting numbers and the "*" (i.e, symbol for future platforms) that are contained within the `#available` condition since they are not literal numbers or operator (thanks to @acclissold for the idea) Additionally, add tests to example.swift to demonstrate highlighting of them. References #56
Thoughts on the newest commit? I highlight the platforms, but skip highlighting the numbers and the Better now 😉? Here's what it looks like with the latest commit (left is Vim, right is Xcode): |
This adds the availability arguments described in the "Attributes" chapter of the "The Swift Programming Language" book. Also expand the list of platform names based on the Swift book. References #56
Latest commit adds some niceties to (Boy this is more work for |
When I saw this issue a while ago, I thought about simply adding I like the stuff in the screenshot you posted buuuuuuuut I don't know how I feel about highlighting all the stuff in |
@@ -142,6 +145,8 @@ syntax keyword swiftAttributes | |||
\ @UIApplicationMain | |||
\ @warn_unused_result | |||
|
|||
syntax keyword swiftConditionStatement #available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be reasonable to group this in the "swiftPreprocessor" group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought about that, but it's not really a pre-processor is it?
But if you're fine with it, I can make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¯\_(ツ)_/¯
I'm fine with it either way. Maybe we could generalize that group since preprocessor is a misnomer anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the Swift book calls them a BuildConfigurationStatement
, which #available
still isn't.
We could call it HashtagStatements
or something :P.
Any thoughts on what we could call the group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, leaving it like this is fine.
Since Xcode doesn't highlight them, we shouldn't either. Keep the highlight group so users can override it. References #56
@aclissold: Oh! Well if Xcode doesn't do it 😛 Changed to remove the highlighting. 😄 I kept the highlight group still, so if anyone else wants, they could still get override the highlighting. |
@ajh17 re operator highlighting, feel free to submit a PR to not highlight them, although keeping the groups might be useful in the future. |
Highlight @available/#available attributes
Thanks guys! |
This adds the new (introduced in Swift 2)
@available
and#available
attributes to the swift syntax file.I chose to add this to the new
swiftConditionalAttribute
(since it's a conditional attribute that is used inif
/guard
statements) rather than the existingswiftAttributes
(which are typically used to apply to functions/classes).If you think that's wrong, I can easily update this.
Resolves #54