Commit Graph

80 Commits

Author SHA1 Message Date
raimon
08016710f2 Add match pattern underscore to hex, binary, octal literals
See also:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html
2016-05-08 16:42:59 +09:00
Keith Smiley
b4262ec767 Only highlight indirect when followed by case 2016-04-24 13:50:37 -07:00
Keith Smiley
3efa034dda Merge pull request #84 from ajh17/typecasts
Add syntax highlighting for type casts
2016-04-24 13:41:58 -07:00
Akshay Hegde
bb98df4563 Fix syntax coloring in string interpolation
Start the match just before the \( part
2016-04-24 13:36:22 -07:00
Akshay Hegde
a2cca58680 Add syntax highlighting for type casts
This commit separates `as` and `is` into their own keyword syntax,
and contains them in a new syntax region for type casts.

Also removes an extraneous `swiftGenericsWrapper` in the `swiftType`
syntax match.

Fixes #48
2016-04-24 13:22:04 -07:00
Keith Smiley
9fb609e321 Merge pull request #82 from ajh17/selector-syntax
Highlight #selector keyword [SE-0022]
2016-04-24 11:44:57 -07:00
Akshay Hegde
d23e21ce38 Implement highlighting for properties and enum members 2016-04-24 11:43:31 -07:00
Akshay Hegde
03140ad483 Highlight #selector keyword [SE-0022]
From swift-evolution:
https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md
2016-04-24 11:43:10 -07:00
Daniel Duan
328a7c3a4c highlight Swift line directive [SE-0034] 2016-03-01 01:12:23 -08:00
Daniel Duan
1817bc4240 highlight Swift buildtin expressions 2016-02-22 15:31:19 -08:00
Daniel Duan
b5c249e9ab add 'associatedtype' as a keyword 2016-02-12 15:49:02 -08:00
Keith Smiley
41d75c07bd Make swiftInterpolatedWrapper only span a single line
This is part of the language and previously broken syntax highlighting
broken everything below it as well. Now the highlighting is fixed as
well. It was fallout from changing the type wrapper to contain ALL.
2016-02-08 15:08:43 -08:00
Keith Smiley
5258bd9892 Swift strings are only allowed to be on a single line
Before the match could go on forever
2016-01-08 16:40:25 -08:00
Keith Smiley
b583247fd7 Allow nested strings in interpolated strings
Previously this broke all following syntax highlighting because it
thought it was continuing a string
2016-01-08 16:38:51 -08:00
Keith Smiley
fa61881d9c Everything contains everything!
This can't possibly be true. But right now somethings haven't been
highlighted correctly because the wrapper types have been blocking them.
Now these are explicitly marked as containing ALL, which works in the
example.swift file. I'm sure we're going to have to back this off, and
we'll do that case by case.
2016-01-08 14:51:04 -08:00
Keith Smiley
d87608dcd1 Operators also should be highlighted in literals 2016-01-08 14:46:20 -08:00
Keith Smiley
7081de3cbe Literal wrappers can contain methods
This fixes a bug where a method call with a trailing [] would be
highlighted incorrectly because a different match trumped the function
call.
2016-01-08 14:42:33 -08:00
Keith Smiley
66474b647a Single forward slash terminates type wrappers
This fixes a problem where comments at the end of a line could be
contained in the highlighting of the prefix. Now matches end 1 character
before their "actual" end
2016-01-08 14:37:03 -08:00
Keith Smiley
98cb48e309 Add new swift comment identifiers 2016-01-08 12:57:22 -08:00
Keith Smiley
5e77f97c4d Force vim to sync 100 lines
This fixes a bug where if you had a very long documentation comment, and
you launched vim and it resumed with only being able to see a portion of
that comment, the comment would not be highlighted correctly. By default
ruby syncs 500 lines so we could probably up this number if needed, but
this should be fine for now.

Closes #49
2015-10-18 13:22:18 -07:00
Keith Smiley
805ed38631 Ignore the - in swift docstring comments
Previously in text such as `- parameter` the `-` was also highlighted.
This change introduces the highlight start operator to make it start
after that character, so now just `parameter` is highlighted.
2015-10-18 13:16:35 -07:00
Keith Smiley
fe3845e820 Add highlighting for doccomments
This highlights the parameter and returns portions of docstrings

Closes #50
2015-10-18 12:57:12 -07:00
Keith Smiley
53022ae8f0 Backtick surrounded words
Closes #62
2015-10-18 11:20:49 -07:00
Keith Smiley
05ffeb0c78 Highlight unnamed closure arguments
Closes #64
2015-10-17 18:09:51 -07:00
Keith Smiley
244063386b Fix backslashes breaking syntax highlighting
Fixes #42
2015-10-17 18:08:14 -07:00
Keith Smiley
215ace628d Merge pull request #57 from ajh17/multiple-protocols
Fix highlighting for multiple protocol conformance
2015-10-17 15:52:26 -07:00
Keith Smiley
1e04ee9224 Merge pull request #56 from ajh17/swift2-available
Highlight @available/#available attributes
2015-10-17 15:49:42 -07:00
Keith Smiley
2eb0aac6a4 Merge pull request #55 from ajh17/underscore-padded-numbers
Fix highlighting for underscore separated numbers
2015-10-17 15:48:11 -07:00
Delisa Mason
4079e6d5e4 Add throw keyword 2015-10-17 15:37:58 -07:00
Kyle Fuller
2800cf2b0a Add missing keywords 2015-10-10 11:20:27 -07:00
Kyle Fuller
6018be30d2 Add atexit keyword 2015-10-10 10:55:13 -07:00
Akshay Hegde
4c6d3c8699 Fix an issue with highlighting multiple protocol conformance
Highlighting would break if a newline was placed before the "{". So,
change the highlighting regex to just keep matching until the new line.

References #57
2015-09-07 11:37:05 -07:00
Akshay Hegde
af39344223 Remove highlighting for availability arguments
Since Xcode doesn't highlight them, we shouldn't either. Keep the
highlight group so users can override it.

References #56
2015-09-07 10:22:40 -07:00
Akshay Hegde
6a2d8be0a2 Fix highlighting for multiple protocol conformance
References #6
References #5
Resolves #47
2015-09-07 03:49:08 -07:00
Akshay Hegde
aee9527621 Add support for availability arguments
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
2015-09-07 02:59:46 -07:00
Akshay Hegde
91cc1e63cb Improve highlighting of #available condition
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
2015-09-07 00:57:11 -07:00
Akshay Hegde
3d9d130b6f Improve parsing of underscore padded numbers
Now handles a case where 1_0_0 wouldn't be highlighted. Also adds yet
more underscore padded number tests to example.swift.

References #55
2015-09-06 23:54:40 -07:00
Akshay Hegde
05fbee827d Allow many underscores for underscore padded number
Swift compiler currently allows multiple underscore in an underscore
padded number. For instance, 1___00 is a valid way to write 100 in
Swift.

Also add more underscore padded numbers in example.swift file for
testing purposes. Thanks to @aclissold for these.

References #55
2015-09-06 23:30:23 -07:00
Akshay Hegde
456c8d3cc7 Rename swiftConditionalAttributes => swiftConditionStatement
References #56
2015-09-06 23:25:24 -07:00
Akshay Hegde
0fdbf9b253 Highlight @available/#available attributes
This adds the new (introduced in Swift 2) @available and #available
attributes to the swift syntax file.

Resolves #54
2015-09-06 22:37:38 -07:00
Akshay Hegde
b616f5eeb4 Fix highlighting for underscore separated numbers
"The Basics" chapter of the official "The Swift Programming Language"
book states that you can pad numbers with underscores to help
readability.

This commit also handles the case where underscore padded numbers can
also contain a period (i.e., underscore padded float/double)

Additionally, added some underscore padded numbers in example/swift.vim
for testing purposes.

Fixes #51
2015-09-06 21:47:25 -07:00
Andrew Clissold
91a7602818 Add @noescape attribute 2015-08-25 11:11:58 -04:00
Akshay Hegde
a3b67038fe Update swift keywords and attributes for Swift 2
This updates the swift.vim syntax file with new keywords and attributes
that were introduced in Swift 2.0

Additional information about these new keyword and attributes may be
found in "The Swift Programming Language" (Swift 2 Prerelease) [1]

[1]: https://itunes.apple.com/us/book/id1002622538
2015-06-12 00:30:22 -07:00
Keith Smiley
48266b6d95 Fix multiple class/protocol conformances
See #6
2015-04-18 10:43:00 -07:00
Keith Smiley
5404d287f6 Fix URL issues, add example
See #37
2015-04-18 10:39:51 -07:00
Keith Smiley
d11cae4af0 Remove swiftLiteralWrapper for now.
I could get this to work. The failed use case is this:

baseURL = "http://www.oaklandpostonline.com/search/?q&tarticle&c[]blogs*"

The start pattern matches the `=` right after baseURL and ends on `[]`
in the URL. I couldn't get this to ignore the swiftString type or ignore
if there was a quote right after the URL. Mainly everything is horrible.

Closes #37
2015-02-22 19:49:03 -06:00
Akshay Hegde
e1f922bb1b Add syntax highlighting for swift methods. 2014-12-14 23:12:16 -08:00
Keith Smiley
f405c0d391 Fix * highlighting
Closes #33
2014-12-14 15:30:23 -08:00
Keith Smiley
2d00be335b Move comment pattern, update division operator
This fixes an issue where the beginning /* in a C-style block comment
was interpreted as an operator. I read somewhere in syntax.txt (I think)
that the order rules appear in the syntax definition file affects the
interpretation. This is one of those times. The comment block needs to
be after the operator definitions.
2014-12-07 16:04:34 -08:00
Keith Smiley
be757db8a8 Remove oneline argument from swiftString
This should fix the issue where, if you start a string which a single
non-matched quote, the string and interpolated string isn't highlighted
until the quote was closed. This seems like a bad idea since strings
only function when they are on a single line and this example:

"foo
" bar

highlights like they can spread over multiple lines. Where `bar` is
highlighted like a keyword and not part of an unclosed string. This is
also how ruby.vim does this so I assume this is the way to do it.

This fixes #28
2014-12-05 19:49:58 -08:00