mirror of
https://github.com/amix/vimrc
synced 2025-07-10 03:25:00 +08:00
add cocoa.vim & swift.vim
This commit is contained in:
6
sources_non_forked/swift.vim/LICENSE
Normal file
6
sources_non_forked/swift.vim/LICENSE
Normal file
@ -0,0 +1,6 @@
|
||||
Copyright (c) 2014 Keith Smiley (http://keith.so)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
37
sources_non_forked/swift.vim/README.md
Normal file
37
sources_non_forked/swift.vim/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Swift.vim
|
||||
|
||||
Syntax and indent files for [Swift](https://developer.apple.com/swift/)
|
||||
|
||||
If you don't have a preferred installation method check out
|
||||
[vim-plug](https://github.com/junegunn/vim-plug).
|
||||
|
||||
## Examples
|
||||
|
||||

|
||||

|
||||
|
||||
## [Syntastic](https://github.com/scrooloose/syntastic/) Integration
|
||||
|
||||
swift.vim can show errors inline from
|
||||
[swift package manager](https://github.com/apple/swift-package-manager/)
|
||||
or from [swiftlint](https://github.com/realm/SwiftLint) using
|
||||
[syntastic](https://github.com/scrooloose/syntastic/).
|
||||
|
||||

|
||||
|
||||
### Usage
|
||||
|
||||
- Install [syntastic](https://github.com/scrooloose/syntastic/)
|
||||
|
||||
- swiftpm integration will be automatically enabled if you're running vim
|
||||
from a directory containing a `Package.swift` file.
|
||||
|
||||
- SwiftLint integration will be automatically enabled if you have
|
||||
SwiftLint installed and if you're running vim from a directory
|
||||
containing a `.swiftlint.yml` file.
|
||||
|
||||
- To enable both at once add this to your vimrc:
|
||||
|
||||
```vim
|
||||
let g:syntastic_swift_checkers = ['swiftpm', 'swiftlint']
|
||||
```
|
48
sources_non_forked/swift.vim/ale_linters/swift/swiftlint.vim
Normal file
48
sources_non_forked/swift.vim/ale_linters/swift/swiftlint.vim
Normal file
@ -0,0 +1,48 @@
|
||||
function! ale_linters#swift#swiftlint#GetExecutable(buffer)
|
||||
if get(g:, 'ale_swift_swiftlint_use_defaults', 0) || filereadable('.swiftlint.yml')
|
||||
return 'swiftlint'
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftlint#Handle(buffer, lines)
|
||||
" Match and ignore file path (anything but ':')
|
||||
" Match and capture line number
|
||||
" Match and capture optional column number
|
||||
" Match and capture warning level ('error' or 'warning')
|
||||
" Match and capture anything in the message
|
||||
let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\)\?:\?\s*\(\w\+\):\s*\(.*\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:line in a:lines
|
||||
let l:match = matchlist(l:line, l:pattern)
|
||||
|
||||
if len(l:match) == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:line_number = l:match[1]
|
||||
let l:column = l:match[2]
|
||||
let l:type = toupper(l:match[3][0])
|
||||
let l:text = l:match[4]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:line_number,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': l:column,
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type,
|
||||
\ })
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('swift', {
|
||||
\ 'name': 'swiftlint',
|
||||
\ 'executable_callback': 'ale_linters#swift#swiftlint#GetExecutable',
|
||||
\ 'command': 'swiftlint lint --use-stdin',
|
||||
\ 'callback': 'ale_linters#swift#swiftlint#Handle',
|
||||
\ })
|
60
sources_non_forked/swift.vim/ale_linters/swift/swiftpm.vim
Normal file
60
sources_non_forked/swift.vim/ale_linters/swift/swiftpm.vim
Normal file
@ -0,0 +1,60 @@
|
||||
if !exists('g:ale_swift_swiftpm_executable')
|
||||
let g:ale_swift_swiftpm_executable = 'swift'
|
||||
endif
|
||||
|
||||
if !exists('g:ale_swift_swiftpm_arguments')
|
||||
let g:ale_swift_swiftpm_arguments = 'build'
|
||||
endif
|
||||
|
||||
function! ale_linters#swift#swiftpm#GetExecutable(buffer)
|
||||
if !filereadable('Package.swift')
|
||||
return ''
|
||||
endif
|
||||
|
||||
return g:ale_swift_swiftpm_executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftpm#GetCommand(buffer)
|
||||
return g:ale_swift_swiftpm_executable
|
||||
\ . ' '
|
||||
\ . g:ale_swift_swiftpm_arguments
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftpm#Handle(buffer, lines)
|
||||
" Match and ignore file path (anything but :)
|
||||
" Match and capture line number
|
||||
" Match and capture column number
|
||||
" Match and capture anything in the message
|
||||
let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\s*error:\s*\(.*\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:line in a:lines
|
||||
let l:match = matchlist(l:line, l:pattern)
|
||||
|
||||
if len(l:match) == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:line_number = l:match[1]
|
||||
let l:column = l:match[2]
|
||||
let l:text = l:match[3]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:line_number,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': l:column,
|
||||
\ 'text': l:text,
|
||||
\ 'type': 'E',
|
||||
\ })
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('swift', {
|
||||
\ 'name': 'swiftpm',
|
||||
\ 'executable_callback': 'ale_linters#swift#swiftpm#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#swift#swiftpm#GetCommand',
|
||||
\ 'callback': 'ale_linters#swift#swiftpm#Handle',
|
||||
\ })
|
9
sources_non_forked/swift.vim/ctags/swift.cnf
Normal file
9
sources_non_forked/swift.vim/ctags/swift.cnf
Normal file
@ -0,0 +1,9 @@
|
||||
--langdef=swift
|
||||
--langmap=swift:.swift
|
||||
--regex-swift=/[[:<:]]class[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/c,class/
|
||||
--regex-swift=/[[:<:]]enum[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/e,enum/
|
||||
--regex-swift=/[[:<:]]func[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/f,function/
|
||||
--regex-swift=/[[:<:]]protocol[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/P,protocol/
|
||||
--regex-swift=/[[:<:]]struct[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/s,struct/
|
||||
--regex-swift=/[[:<:]]extension[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/E,extension/
|
||||
--regex-swift=/[[:<:]]typealias[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/t,typealias/
|
124
sources_non_forked/swift.vim/example/MainViewController.swift
Normal file
124
sources_non_forked/swift.vim/example/MainViewController.swift
Normal file
@ -0,0 +1,124 @@
|
||||
//
|
||||
// MainViewController.swift
|
||||
// HackerNews
|
||||
//
|
||||
// Copyright (c) 2014 Amit Burstein. All rights reserved.
|
||||
// See LICENSE for licensing information.
|
||||
//
|
||||
// Abstract:
|
||||
// Handles fetching and displaying posts from Hacker News.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import QuartzCore
|
||||
|
||||
class MainViewController: UIViewController, UITableViewDataSource {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let postCellIdentifier = "PostCell"
|
||||
let showBrowserIdentifier = "ShowBrowser"
|
||||
var postFilter = PostFilterType.Top
|
||||
var posts = HNPost[]()
|
||||
var refreshControl = UIRefreshControl()
|
||||
@IBOutlet var tableView: UITableView
|
||||
|
||||
// MARK: Lifecycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
configureUI()
|
||||
fetchPosts()
|
||||
}
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
tableView.deselectRowAtIndexPath(tableView.indexPathForSelectedRow(), animated: animated)
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func configureUI() {
|
||||
refreshControl.addTarget(self, action: "fetchPosts", forControlEvents: .ValueChanged)
|
||||
refreshControl.attributedTitle = NSAttributedString(string: "Pull to Refresh")
|
||||
tableView.insertSubview(refreshControl, atIndex: 0)
|
||||
}
|
||||
|
||||
func fetchPosts() {
|
||||
UIApplication.sharedApplication().networkActivityIndicatorVisible = true;
|
||||
|
||||
HNManager.sharedManager().loadPostsWithFilter(postFilter, completion: { posts in
|
||||
if (posts != nil && posts.count > 0) {
|
||||
self.posts = posts as HNPost[]
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
self.tableView.reloadSections(NSIndexSet(index: 0), withRowAnimation: .Fade)
|
||||
self.refreshControl.endRefreshing()
|
||||
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
|
||||
})
|
||||
} else {
|
||||
println("Could not fetch posts!")
|
||||
self.refreshControl.endRefreshing()
|
||||
UIApplication.sharedApplication().networkActivityIndicatorVisible = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func stylePostCellAsRead(cell: UITableViewCell) {
|
||||
cell.textLabel.textColor = UIColor(red: 119/255.0, green: 119/255.0, blue: 119/255.0, alpha: 1)
|
||||
cell.detailTextLabel.textColor = UIColor(red: 153/255.0, green: 153/255.0, blue: 153/255.0, alpha: 1)
|
||||
}
|
||||
|
||||
// MARK: UITableViewDataSource
|
||||
|
||||
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
|
||||
return posts.count
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier(postCellIdentifier) as UITableViewCell
|
||||
|
||||
let post = posts[indexPath.row]
|
||||
|
||||
if HNManager.sharedManager().hasUserReadPost(post) {
|
||||
stylePostCellAsRead(cell)
|
||||
}
|
||||
|
||||
cell.textLabel.text = post.Title
|
||||
cell.detailTextLabel.text = "\(post.Points) points by \(post.Username)"
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
// MARK: UIViewController
|
||||
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) {
|
||||
if segue.identifier == showBrowserIdentifier {
|
||||
let webView = segue.destinationViewController as BrowserViewController
|
||||
let cell = sender as UITableViewCell
|
||||
let post = posts[tableView.indexPathForCell(cell).row]
|
||||
|
||||
HNManager.sharedManager().setMarkAsReadForPost(post)
|
||||
stylePostCellAsRead(cell)
|
||||
|
||||
webView.post = post
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: IBActions
|
||||
|
||||
@IBAction func changePostFilter(sender: UISegmentedControl) {
|
||||
switch sender.selectedSegmentIndex {
|
||||
case 0:
|
||||
postFilter = .Top
|
||||
fetchPosts()
|
||||
case 1:
|
||||
postFilter = .New
|
||||
fetchPosts()
|
||||
case 2:
|
||||
postFilter = .Ask
|
||||
fetchPosts()
|
||||
default:
|
||||
println("Bad segment index!")
|
||||
}
|
||||
}
|
||||
}
|
11
sources_non_forked/swift.vim/example/URL.swift
Normal file
11
sources_non_forked/swift.vim/example/URL.swift
Normal file
@ -0,0 +1,11 @@
|
||||
import UIKit
|
||||
|
||||
class Foo: FooViewController, BarScrollable {
|
||||
|
||||
var canScroll = false
|
||||
|
||||
override func viewDidLoad() {
|
||||
baseURL = "http://www.oaklandpostonline.com/search/?q=&t=article&c[]=blogs*"
|
||||
super.viewDidLoad()
|
||||
}
|
||||
}
|
361
sources_non_forked/swift.vim/example/example.swift
Normal file
361
sources_non_forked/swift.vim/example/example.swift
Normal file
@ -0,0 +1,361 @@
|
||||
#!/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -i
|
||||
|
||||
// This is a comment
|
||||
|
||||
let foo = 5 // another comment
|
||||
|
||||
/* this is also a comment */
|
||||
|
||||
// If statements so the indented comments are valid
|
||||
if foo {
|
||||
/* this is an indented comment */
|
||||
}
|
||||
|
||||
if foo {
|
||||
/* this is a multi level indented comment /* you know */ */
|
||||
}
|
||||
|
||||
// comments check splelling
|
||||
|
||||
/* this is
|
||||
a multi-line
|
||||
/* you know */
|
||||
|
||||
/** foo
|
||||
bar
|
||||
*/
|
||||
|
||||
comment
|
||||
*/
|
||||
|
||||
/// foo bar
|
||||
|
||||
|
||||
"this is a string no splell checking"
|
||||
"this is a string\" with an escaped quote"
|
||||
|
||||
// TODO: This is a todo comment
|
||||
// XXX: This is another todo comment
|
||||
// FIXME: this is another todo comment
|
||||
// NOTE: this is another todo comment
|
||||
/* TODO multiple */
|
||||
|
||||
// MARK: this is a marker
|
||||
|
||||
if foo {
|
||||
// this is a indented comment
|
||||
}
|
||||
|
||||
5 // int
|
||||
|
||||
5.5 // float
|
||||
5e-2
|
||||
5E2
|
||||
5.5E-2
|
||||
5.5e2
|
||||
5.5f2
|
||||
5.5abc5.5 // broken
|
||||
|
||||
0xa2ef // hex
|
||||
0x123P432
|
||||
0xa_2ef // hex with underscore
|
||||
0x13p-43
|
||||
0x13r-43
|
||||
0x213zdf // broken hex
|
||||
|
||||
0b10101 // binary
|
||||
0b1010_1 // binary with underscore
|
||||
0b1234 // broken binary
|
||||
|
||||
0o567 // octal
|
||||
0o56_7 // octal with underscore
|
||||
0o5689 // broken octal
|
||||
|
||||
1_000_000 // underscore separated million
|
||||
1_000_0000_ // broken underscore separated number
|
||||
1_000_0000. // broken underscore separated float
|
||||
1_000_000.000_000_1 // just over one million
|
||||
1_18181888_2.1.1 // broken underscore padded double
|
||||
1_18181888_2.1 // valid according to swift repl
|
||||
1_0_0 // valid 100
|
||||
1_0_000.2 // valid 10000.2
|
||||
1_____0.2________20___2 // also valid 10.2202
|
||||
4__3.2_33_33 // valid 43.233
|
||||
|
||||
// Operators
|
||||
~
|
||||
!
|
||||
%
|
||||
^
|
||||
&
|
||||
2 * 2
|
||||
-
|
||||
+
|
||||
=
|
||||
|
|
||||
2 / 5
|
||||
.
|
||||
>
|
||||
<
|
||||
|
||||
a != b
|
||||
a != b
|
||||
a !== b
|
||||
a !== b
|
||||
%=
|
||||
&%
|
||||
&&
|
||||
&&=
|
||||
let a = 10 &* 20
|
||||
&+
|
||||
&-
|
||||
8 &/ 20
|
||||
&=
|
||||
let a *= 20
|
||||
++
|
||||
+=
|
||||
--
|
||||
-=
|
||||
..
|
||||
...
|
||||
let b = 50 /= 20
|
||||
<<
|
||||
<=
|
||||
=<<
|
||||
==
|
||||
===
|
||||
>=
|
||||
>>
|
||||
>>=
|
||||
^=
|
||||
|=
|
||||
||
|
||||
||=
|
||||
~=
|
||||
|
||||
// Custom Operators
|
||||
infix operator ~ {
|
||||
precedence 20 // Define precedence
|
||||
associativity none // Define associativity
|
||||
}
|
||||
|
||||
true
|
||||
false
|
||||
|
||||
class Shape : NSObject {
|
||||
var foo: String
|
||||
var qux: String = "abcd"
|
||||
let bar = String?[]()
|
||||
let baz = String()?
|
||||
let foo = Int()
|
||||
|
||||
init(thing: String) {
|
||||
foo = thing
|
||||
super.init(thing)
|
||||
let bar:String= "123"
|
||||
|
||||
bar!
|
||||
}
|
||||
|
||||
func foo(thing1 : String, 2thing : Int52) {
|
||||
|
||||
}
|
||||
|
||||
func bar(thing: String?){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
import Cocoa
|
||||
|
||||
struct Thing: NSString {
|
||||
var foo : Int
|
||||
}
|
||||
|
||||
enum Card : Int {
|
||||
case Spade = 1
|
||||
case Heart
|
||||
case Diamond
|
||||
case Club
|
||||
indirect case Foo(a: Card)
|
||||
}
|
||||
|
||||
let indirect = 5
|
||||
|
||||
struct foo : bar {
|
||||
switch (foo) {
|
||||
case foo:
|
||||
foo
|
||||
case bar:
|
||||
default:
|
||||
stuff
|
||||
case baz:
|
||||
fuck
|
||||
case bar:
|
||||
bafsd
|
||||
}
|
||||
|
||||
func foo() {
|
||||
|
||||
}
|
||||
|
||||
func bar(asdf: String) -> Bool {
|
||||
|
||||
}
|
||||
|
||||
func baz() -> (Foo, Bar)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
func asdf<T>() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
struct ArgumentList {
|
||||
var arguments: String[]
|
||||
|
||||
init(argv: UnsafePointer<CString>,
|
||||
count: CInt)
|
||||
{
|
||||
foo
|
||||
}
|
||||
}
|
||||
|
||||
let a : UnsafePointer<CString>
|
||||
|
||||
func foo<T: Sequence>() {
|
||||
|
||||
}
|
||||
|
||||
init(argv: UnsafePointer<CString>, count: CInt) {
|
||||
for i in 1..count {
|
||||
let index = Int(i)
|
||||
let arg = String.fromCString(argv[index])
|
||||
arguments.append(arg)
|
||||
}
|
||||
}
|
||||
|
||||
func simpleDescription() -> String {
|
||||
return "A shape with \(numberOfSides.toRaw()) sides."
|
||||
}
|
||||
|
||||
let library = [
|
||||
Movie(name: "foo bar",
|
||||
dfasdfsdfdirector: "someone",
|
||||
foo: "bar",
|
||||
bazzzer: "qux")
|
||||
]
|
||||
|
||||
|
||||
foo as? String
|
||||
let foo : Int = bar ?? 5
|
||||
|
||||
let arg: String = "123"
|
||||
hello<String>(arg, arg2: 1.0, arg3: arg, arg4: "foo", arg5: false)
|
||||
|
||||
|
||||
class MainViewController: UIViewController, UITableViewDataSource {}
|
||||
|
||||
@IBAction func changePostFilter(sender: UISegmentedControl) {}
|
||||
override func prepareForSegue(segue: UIStoryboardSegue,
|
||||
sender: AnyObject) {}
|
||||
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {}
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {}
|
||||
lazy var foo : String
|
||||
|
||||
#if foo
|
||||
bar
|
||||
#elseif baz
|
||||
qux
|
||||
#else
|
||||
quix
|
||||
#endif
|
||||
|
||||
client.host = "example.com"
|
||||
client.pathPrefix = "/foo/"
|
||||
|
||||
@available(*, unavailable, renamed="bar", introduced=1.0, deprecated=2.2, message="hi")
|
||||
func foo () {
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
if foo {
|
||||
foobar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let foo = CGRectMake(0, (5 - 2),
|
||||
100, 200)
|
||||
|
||||
|
||||
let dict = [
|
||||
"foo": "Bar",
|
||||
"nest": [
|
||||
"fadsf",
|
||||
]
|
||||
]
|
||||
|
||||
if #available(OSX 10.10.3, *) {
|
||||
// Use APIs OS X 10.10.3 and onwards
|
||||
}
|
||||
if #available(watchOS 2, iOS 9.0, OSX 10.11, *) {
|
||||
// APIs available to watchOS 2.0, iOS 9.0, OSX 10.11 and onwards
|
||||
}
|
||||
|
||||
// Tests backslashes in strings
|
||||
"\\".uppercaseString()
|
||||
"foo \(1 + 1)"
|
||||
string.rangeOfString("^/Date\\(")
|
||||
|
||||
public var `extension`: String?
|
||||
|
||||
/**
|
||||
This is the comment body
|
||||
|
||||
- parameter first: The first parameter
|
||||
- Parameter first: The first parameter
|
||||
|
||||
- returns: Some value
|
||||
*/
|
||||
|
||||
public let fareEstimate: FareEstimate //= (nil, nil) // comment should be highlighted as comment
|
||||
|
||||
// optionalFrom should be highlighted the same way
|
||||
// Operator should also be highlighted
|
||||
key = map.optionalFrom("string") ?? []
|
||||
key = map.optionalFrom("string")
|
||||
thing = map.optionalFrom("string") ?? .Fallback
|
||||
|
||||
// This should not break all highlighting
|
||||
print("Copying \(NSProcessInfo().environment["SCRIPT_INPUT_FILE_\(index)"]!)")
|
||||
// Neither should this
|
||||
return addressParts.count == 2 ? addressParts[1] : "\(addressParts[1]), \(addressParts[2])"
|
||||
|
||||
// This is multiline garbage
|
||||
"foo
|
||||
bar
|
||||
baz"
|
||||
|
||||
guard let path = NSBundle.mainBundle().pathForResource(imageName, ofType: "png"),
|
||||
let data = NSData(contentsOfFile: path),
|
||||
let data = NSData(contentsOfFile: path) else
|
||||
{
|
||||
}
|
||||
|
||||
UIView.animateWithDuration(duration, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: .CurveEaseInOut, animations: {
|
||||
view.backgroundColor = UIColor.redColor()
|
||||
}) { finished in
|
||||
print("indent?")
|
||||
}
|
||||
|
||||
// Indent last line should hold
|
||||
self.init(className: "Item", dictionary: [
|
||||
"identifier": item.identifier,
|
||||
"title": item.title,
|
||||
"link": item.link,
|
||||
"date": item.date,
|
||||
"summary": item.summary])
|
||||
|
||||
XCAssertEqual(variables as NSDictionary, expectedVariables as NSDictionary, "\(template)")
|
12
sources_non_forked/swift.vim/ftdetect/swift.vim
Normal file
12
sources_non_forked/swift.vim/ftdetect/swift.vim
Normal file
@ -0,0 +1,12 @@
|
||||
autocmd BufNewFile,BufRead *.swift set filetype=swift
|
||||
autocmd BufRead * call s:Swift()
|
||||
function! s:Swift()
|
||||
if !empty(&filetype)
|
||||
return
|
||||
endif
|
||||
|
||||
let line = getline(1)
|
||||
if line =~ "^#!.*swift"
|
||||
setfiletype swift
|
||||
endif
|
||||
endfunction
|
4
sources_non_forked/swift.vim/ftplugin/swift.vim
Normal file
4
sources_non_forked/swift.vim/ftplugin/swift.vim
Normal file
@ -0,0 +1,4 @@
|
||||
setlocal commentstring=//\ %s
|
||||
" @-@ adds the literal @ to iskeyword for @IBAction and similar
|
||||
setlocal iskeyword+=@-@,#
|
||||
setlocal completefunc=syntaxcomplete#Complete
|
238
sources_non_forked/swift.vim/indent/swift.vim
Normal file
238
sources_non_forked/swift.vim/indent/swift.vim
Normal file
@ -0,0 +1,238 @@
|
||||
" File: swift.vim
|
||||
" Author: Keith Smiley
|
||||
" Description: The indent file for Swift
|
||||
" Last Modified: December 05, 2014
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
setlocal nosmartindent
|
||||
setlocal indentkeys-=e
|
||||
setlocal indentkeys+=0]
|
||||
setlocal indentexpr=SwiftIndent()
|
||||
|
||||
function! s:NumberOfMatches(char, string, index)
|
||||
let instances = 0
|
||||
let i = 0
|
||||
while i < strlen(a:string)
|
||||
if a:string[i] == a:char && !s:IsExcludedFromIndentAtPosition(a:index, i + 1)
|
||||
let instances += 1
|
||||
endif
|
||||
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
return instances
|
||||
endfunction
|
||||
|
||||
function! s:SyntaxNameAtPosition(line, column)
|
||||
return synIDattr(synID(a:line, a:column, 0), "name")
|
||||
endfunction
|
||||
|
||||
function! s:SyntaxName()
|
||||
return s:SyntaxNameAtPosition(line("."), col("."))
|
||||
endfunction
|
||||
|
||||
function! s:IsExcludedFromIndentAtPosition(line, column)
|
||||
let name = s:SyntaxNameAtPosition(a:line, a:column)
|
||||
return name ==# "swiftComment" || name ==# "swiftString"
|
||||
endfunction
|
||||
|
||||
function! s:IsExcludedFromIndent()
|
||||
return s:SyntaxName() ==# "swiftComment" || s:SyntaxName() ==# "swiftString"
|
||||
endfunction
|
||||
|
||||
function! s:IsCommentLine(lnum)
|
||||
return synIDattr(synID(a:lnum,
|
||||
\ match(getline(a:lnum), "\S") + 1, 0), "name")
|
||||
\ ==# "swiftComment"
|
||||
endfunction
|
||||
|
||||
function! SwiftIndent(...)
|
||||
let clnum = a:0 ? a:1 : v:lnum
|
||||
|
||||
let line = getline(clnum)
|
||||
let previousNum = prevnonblank(clnum - 1)
|
||||
while s:IsCommentLine(previousNum) != 0
|
||||
let previousNum = prevnonblank(previousNum - 1)
|
||||
endwhile
|
||||
|
||||
let previous = getline(previousNum)
|
||||
let cindent = cindent(clnum)
|
||||
let previousIndent = indent(previousNum)
|
||||
|
||||
let numOpenParens = s:NumberOfMatches("(", previous, previousNum)
|
||||
let numCloseParens = s:NumberOfMatches(")", previous, previousNum)
|
||||
let numOpenBrackets = s:NumberOfMatches("{", previous, previousNum)
|
||||
let numCloseBrackets = s:NumberOfMatches("}", previous, previousNum)
|
||||
|
||||
let currentOpenBrackets = s:NumberOfMatches("{", line, clnum)
|
||||
let currentCloseBrackets = s:NumberOfMatches("}", line, clnum)
|
||||
|
||||
let numOpenSquare = s:NumberOfMatches("[", previous, previousNum)
|
||||
let numCloseSquare = s:NumberOfMatches("]", previous, previousNum)
|
||||
|
||||
let currentCloseSquare = s:NumberOfMatches("]", line, clnum)
|
||||
if numOpenSquare > numCloseSquare && currentCloseSquare < 1
|
||||
return previousIndent + shiftwidth()
|
||||
endif
|
||||
|
||||
if currentCloseSquare > 0 && line !~ '\v\[.*\]'
|
||||
let column = col(".")
|
||||
call cursor(line("."), 1)
|
||||
let openingSquare = searchpair("\\[", "", "\\]", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line("."), column)
|
||||
|
||||
if openingSquare == 0
|
||||
return -1
|
||||
endif
|
||||
|
||||
" - Line starts with closing square, indent as opening square
|
||||
if line =~ '\v^\s*]'
|
||||
return indent(openingSquare)
|
||||
endif
|
||||
|
||||
" - Line contains closing square and more, indent a level above opening
|
||||
return indent(openingSquare) + shiftwidth()
|
||||
endif
|
||||
|
||||
if line =~ ":$"
|
||||
let switch = search("switch", "bWn")
|
||||
return indent(switch)
|
||||
elseif previous =~ ":$"
|
||||
return previousIndent + shiftwidth()
|
||||
endif
|
||||
|
||||
if numOpenParens == numCloseParens
|
||||
if numOpenBrackets > numCloseBrackets
|
||||
if currentCloseBrackets > currentOpenBrackets || line =~ "\\v^\\s*}"
|
||||
let column = col(".")
|
||||
call cursor(line("."), 1)
|
||||
let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line("."), column)
|
||||
if openingBracket == 0
|
||||
return -1
|
||||
else
|
||||
return indent(openingBracket)
|
||||
endif
|
||||
endif
|
||||
|
||||
return previousIndent + shiftwidth()
|
||||
elseif previous =~ "}.*{"
|
||||
if line =~ "\\v^\\s*}"
|
||||
return previousIndent
|
||||
endif
|
||||
|
||||
return previousIndent + shiftwidth()
|
||||
elseif line =~ "}.*{"
|
||||
let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()")
|
||||
return indent(openingBracket)
|
||||
elseif currentCloseBrackets > currentOpenBrackets
|
||||
let column = col(".")
|
||||
call cursor(line("."), 1)
|
||||
let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line("."), column)
|
||||
|
||||
let bracketLine = getline(openingBracket)
|
||||
|
||||
let numOpenParensBracketLine = s:NumberOfMatches("(", bracketLine, openingBracket)
|
||||
let numCloseParensBracketLine = s:NumberOfMatches(")", bracketLine, openingBracket)
|
||||
if numCloseParensBracketLine > numOpenParensBracketLine
|
||||
let line = line(".")
|
||||
let column = col(".")
|
||||
call cursor(openingParen, column)
|
||||
let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line, column)
|
||||
return indent(openingParen)
|
||||
endif
|
||||
return indent(openingBracket)
|
||||
else
|
||||
" - Current line is blank, and the user presses 'o'
|
||||
return previousIndent
|
||||
endif
|
||||
endif
|
||||
|
||||
if numCloseParens > 0
|
||||
if currentOpenBrackets > 0 || currentCloseBrackets > 0
|
||||
if currentOpenBrackets > 0
|
||||
if numOpenBrackets > numCloseBrackets
|
||||
return previousIndent + shiftwidth()
|
||||
endif
|
||||
|
||||
if line =~ "}.*{"
|
||||
let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()")
|
||||
return indent(openingBracket)
|
||||
endif
|
||||
|
||||
if numCloseParens > numOpenParens
|
||||
let line = line(".")
|
||||
let column = col(".")
|
||||
call cursor(line - 1, column)
|
||||
let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line, column)
|
||||
return indent(openingParen)
|
||||
endif
|
||||
|
||||
return previousIndent
|
||||
endif
|
||||
|
||||
if currentCloseBrackets > 0
|
||||
let openingBracket = searchpair("{", "", "}", "bWn", "s:IsExcludedFromIndent()")
|
||||
return indent(openingBracket)
|
||||
endif
|
||||
|
||||
return cindent
|
||||
endif
|
||||
|
||||
if numCloseParens < numOpenParens
|
||||
if numOpenBrackets > numCloseBrackets
|
||||
return previousIndent + shiftwidth()
|
||||
endif
|
||||
|
||||
let previousParen = match(previous, "(")
|
||||
return indent(previousParen) + shiftwidth()
|
||||
endif
|
||||
|
||||
if numOpenBrackets > numCloseBrackets
|
||||
let line = line(".")
|
||||
let column = col(".")
|
||||
call cursor(previousNum, column)
|
||||
let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line, column)
|
||||
return indent(openingParen) + shiftwidth()
|
||||
endif
|
||||
|
||||
" - Previous line has close then open braces, indent previous + 1 'sw'
|
||||
if previous =~ "}.*{"
|
||||
return previousIndent + shiftwidth()
|
||||
endif
|
||||
|
||||
let line = line(".")
|
||||
let column = col(".")
|
||||
call cursor(previousNum, column)
|
||||
let openingParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()")
|
||||
call cursor(line, column)
|
||||
|
||||
return indent(openingParen)
|
||||
endif
|
||||
|
||||
" - Line above has (unmatched) open paren, next line needs indent
|
||||
if numOpenParens > 0
|
||||
let savePosition = getcurpos()
|
||||
" Must be at EOL because open paren has to be above (left of) the cursor
|
||||
call cursor(previousNum, col("$"))
|
||||
let previousParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()")
|
||||
call setpos(".", savePosition)
|
||||
return indent(previousParen) + shiftwidth()
|
||||
endif
|
||||
|
||||
return cindent
|
||||
endfunction
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
14
sources_non_forked/swift.vim/plugin/swift.vim
Normal file
14
sources_non_forked/swift.vim/plugin/swift.vim
Normal file
@ -0,0 +1,14 @@
|
||||
let g:tagbar_type_swift = {
|
||||
\ 'ctagstype': 'swift',
|
||||
\ 'kinds': [
|
||||
\ 'P:protocol',
|
||||
\ 'c:class',
|
||||
\ 's:struct',
|
||||
\ 'e:enum',
|
||||
\ 'E:extension',
|
||||
\ 'f:function',
|
||||
\ 't:typealias'
|
||||
\ ],
|
||||
\ 'sort': 0,
|
||||
\ 'deffile': expand('<sfile>:p:h:h') . '/ctags/swift.cnf'
|
||||
\ }
|
BIN
sources_non_forked/swift.vim/screenshots/screen.png
Normal file
BIN
sources_non_forked/swift.vim/screenshots/screen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
sources_non_forked/swift.vim/screenshots/screen2.png
Normal file
BIN
sources_non_forked/swift.vim/screenshots/screen2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
sources_non_forked/swift.vim/screenshots/screen3.png
Normal file
BIN
sources_non_forked/swift.vim/screenshots/screen3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
290
sources_non_forked/swift.vim/syntax/swift.vim
Normal file
290
sources_non_forked/swift.vim/syntax/swift.vim
Normal file
@ -0,0 +1,290 @@
|
||||
" File: swift.vim
|
||||
" Author: Keith Smiley
|
||||
" Description: Runtime files for Swift
|
||||
" Last Modified: June 15, 2014
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Comments
|
||||
" Shebang
|
||||
syntax match swiftShebang "\v#!.*$"
|
||||
|
||||
" Comment contained keywords
|
||||
syntax keyword swiftTodos contained TODO XXX FIXME NOTE
|
||||
syntax keyword swiftMarker contained MARK
|
||||
|
||||
" In comment identifiers
|
||||
function! s:CommentKeywordMatch(keyword)
|
||||
execute "syntax match swiftDocString \"\\v^\\s*-\\s*". a:keyword . "\\W\"hs=s+1,he=e-1 contained"
|
||||
endfunction
|
||||
|
||||
syntax case ignore
|
||||
|
||||
call s:CommentKeywordMatch("attention")
|
||||
call s:CommentKeywordMatch("author")
|
||||
call s:CommentKeywordMatch("authors")
|
||||
call s:CommentKeywordMatch("bug")
|
||||
call s:CommentKeywordMatch("complexity")
|
||||
call s:CommentKeywordMatch("copyright")
|
||||
call s:CommentKeywordMatch("date")
|
||||
call s:CommentKeywordMatch("experiment")
|
||||
call s:CommentKeywordMatch("important")
|
||||
call s:CommentKeywordMatch("invariant")
|
||||
call s:CommentKeywordMatch("note")
|
||||
call s:CommentKeywordMatch("parameter")
|
||||
call s:CommentKeywordMatch("postcondition")
|
||||
call s:CommentKeywordMatch("precondition")
|
||||
call s:CommentKeywordMatch("remark")
|
||||
call s:CommentKeywordMatch("remarks")
|
||||
call s:CommentKeywordMatch("requires")
|
||||
call s:CommentKeywordMatch("returns")
|
||||
call s:CommentKeywordMatch("see")
|
||||
call s:CommentKeywordMatch("since")
|
||||
call s:CommentKeywordMatch("throws")
|
||||
call s:CommentKeywordMatch("todo")
|
||||
call s:CommentKeywordMatch("version")
|
||||
call s:CommentKeywordMatch("warning")
|
||||
|
||||
syntax case match
|
||||
delfunction s:CommentKeywordMatch
|
||||
|
||||
|
||||
" Literals
|
||||
" Strings
|
||||
syntax region swiftString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=swiftInterpolatedWrapper oneline
|
||||
syntax region swiftInterpolatedWrapper start="\v[^\\]\zs\\\(\s*" end="\v\s*\)" contained containedin=swiftString contains=swiftInterpolatedString,swiftString oneline
|
||||
syntax match swiftInterpolatedString "\v\w+(\(\))?" contained containedin=swiftInterpolatedWrapper oneline
|
||||
|
||||
" Numbers
|
||||
syntax match swiftNumber "\v<\d+>"
|
||||
syntax match swiftNumber "\v<(\d+_+)+\d+(\.\d+(_+\d+)*)?>"
|
||||
syntax match swiftNumber "\v<\d+\.\d+>"
|
||||
syntax match swiftNumber "\v<\d*\.?\d+([Ee]-?)?\d+>"
|
||||
syntax match swiftNumber "\v<0x[[:xdigit:]_]+([Pp]-?)?\x+>"
|
||||
syntax match swiftNumber "\v<0b[01_]+>"
|
||||
syntax match swiftNumber "\v<0o[0-7_]+>"
|
||||
|
||||
" BOOLs
|
||||
syntax keyword swiftBoolean
|
||||
\ true
|
||||
\ false
|
||||
|
||||
|
||||
" Operators
|
||||
syntax match swiftOperator "\v\~"
|
||||
syntax match swiftOperator "\v\s+!"
|
||||
syntax match swiftOperator "\v\%"
|
||||
syntax match swiftOperator "\v\^"
|
||||
syntax match swiftOperator "\v\&"
|
||||
syntax match swiftOperator "\v\*"
|
||||
syntax match swiftOperator "\v-"
|
||||
syntax match swiftOperator "\v\+"
|
||||
syntax match swiftOperator "\v\="
|
||||
syntax match swiftOperator "\v\|"
|
||||
syntax match swiftOperator "\v\/"
|
||||
syntax match swiftOperator "\v\."
|
||||
syntax match swiftOperator "\v\<"
|
||||
syntax match swiftOperator "\v\>"
|
||||
syntax match swiftOperator "\v\?\?"
|
||||
|
||||
" Methods/Functions/Properties
|
||||
syntax match swiftMethod "\(\.\)\@<=\w\+\((\)\@="
|
||||
syntax match swiftProperty "\(\.\)\@<=\<\w\+\>(\@!"
|
||||
|
||||
" Swift closure arguments
|
||||
syntax match swiftClosureArgument "\$\d\+\(\.\d\+\)\?"
|
||||
|
||||
syntax match swiftAvailability "\v((\*(\s*,\s*[a-zA-Z="0-9.]+)*)|(\w+\s+\d+(\.\d+(.\d+)?)?\s*,\s*)+\*)" contains=swiftString
|
||||
syntax keyword swiftPlatforms OSX iOS watchOS OSXApplicationExtension iOSApplicationExtension contained containedin=swiftAvailability
|
||||
syntax keyword swiftAvailabilityArg renamed unavailable introduced deprecated obsoleted message contained containedin=swiftAvailability
|
||||
|
||||
" Keywords {{{
|
||||
syntax keyword swiftKeywords
|
||||
\ associatedtype
|
||||
\ associativity
|
||||
\ atexit
|
||||
\ break
|
||||
\ case
|
||||
\ catch
|
||||
\ class
|
||||
\ continue
|
||||
\ convenience
|
||||
\ default
|
||||
\ defer
|
||||
\ deinit
|
||||
\ didSet
|
||||
\ do
|
||||
\ dynamic
|
||||
\ else
|
||||
\ extension
|
||||
\ fallthrough
|
||||
\ fileprivate
|
||||
\ final
|
||||
\ for
|
||||
\ func
|
||||
\ get
|
||||
\ guard
|
||||
\ if
|
||||
\ import
|
||||
\ in
|
||||
\ infix
|
||||
\ init
|
||||
\ inout
|
||||
\ internal
|
||||
\ lazy
|
||||
\ let
|
||||
\ mutating
|
||||
\ nil
|
||||
\ nonmutating
|
||||
\ operator
|
||||
\ optional
|
||||
\ override
|
||||
\ postfix
|
||||
\ precedence
|
||||
\ precedencegroup
|
||||
\ prefix
|
||||
\ private
|
||||
\ protocol
|
||||
\ public
|
||||
\ repeat
|
||||
\ required
|
||||
\ return
|
||||
\ self
|
||||
\ set
|
||||
\ static
|
||||
\ subscript
|
||||
\ super
|
||||
\ switch
|
||||
\ throw
|
||||
\ try
|
||||
\ typealias
|
||||
\ unowned
|
||||
\ var
|
||||
\ weak
|
||||
\ where
|
||||
\ while
|
||||
\ willSet
|
||||
|
||||
syntax keyword swiftDefinitionModifier
|
||||
\ rethrows
|
||||
\ throws
|
||||
|
||||
syntax match swiftMultiwordKeywords "indirect case"
|
||||
syntax match swiftMultiwordKeywords "indirect enum"
|
||||
" }}}
|
||||
|
||||
" Names surrounded by backticks. This aren't limited to keywords because 1)
|
||||
" Swift doesn't limit them to keywords and 2) I couldn't make the keywords not
|
||||
" highlight at the same time
|
||||
syntax region swiftEscapedReservedWord start="`" end="`" oneline
|
||||
|
||||
syntax keyword swiftAttributes
|
||||
\ @assignment
|
||||
\ @autoclosure
|
||||
\ @available
|
||||
\ @convention
|
||||
\ @discardableResult
|
||||
\ @exported
|
||||
\ @IBAction
|
||||
\ @IBDesignable
|
||||
\ @IBInspectable
|
||||
\ @IBOutlet
|
||||
\ @noescape
|
||||
\ @nonobjc
|
||||
\ @noreturn
|
||||
\ @NSApplicationMain
|
||||
\ @NSCopying
|
||||
\ @NSManaged
|
||||
\ @objc
|
||||
\ @testable
|
||||
\ @UIApplicationMain
|
||||
\ @warn_unused_result
|
||||
|
||||
syntax keyword swiftConditionStatement #available
|
||||
|
||||
syntax keyword swiftStructure
|
||||
\ struct
|
||||
\ enum
|
||||
|
||||
syntax keyword swiftDebugIdentifier
|
||||
\ #column
|
||||
\ #file
|
||||
\ #function
|
||||
\ #line
|
||||
\ __COLUMN__
|
||||
\ __FILE__
|
||||
\ __FUNCTION__
|
||||
\ __LINE__
|
||||
|
||||
syntax keyword swiftLineDirective #setline
|
||||
|
||||
syntax region swiftTypeWrapper start="\v:\s*" skip="\s*,\s*$*\s*" end="$\|/"me=e-1 contains=ALLBUT,swiftInterpolatedWrapper transparent
|
||||
syntax region swiftTypeCastWrapper start="\(as\|is\)\(!\|?\)\=\s\+" end="\v(\s|$|\{)" contains=swiftType,swiftCastKeyword keepend transparent oneline
|
||||
syntax region swiftGenericsWrapper start="\v\<" end="\v\>" contains=swiftType transparent oneline
|
||||
syntax region swiftLiteralWrapper start="\v\=\s*" skip="\v[^\[\]]\(\)" end="\v(\[\]|\(\))" contains=ALL transparent oneline
|
||||
syntax region swiftReturnWrapper start="\v-\>\s*" end="\v(\{|$)" contains=swiftType transparent oneline
|
||||
syntax match swiftType "\v<\u\w*" contained containedin=swiftTypeWrapper,swiftLiteralWrapper,swiftGenericsWrapper,swiftTypeCastWrapper
|
||||
syntax match swiftTypeDeclaration /->/ skipwhite nextgroup=swiftType
|
||||
|
||||
syntax keyword swiftImports import
|
||||
syntax keyword swiftCastKeyword is as contained
|
||||
|
||||
" 'preprocesor' stuff
|
||||
syntax keyword swiftPreprocessor
|
||||
\ #if
|
||||
\ #elseif
|
||||
\ #else
|
||||
\ #endif
|
||||
\ #selector
|
||||
|
||||
|
||||
" Comment patterns
|
||||
syntax match swiftComment "\v\/\/.*$"
|
||||
\ contains=swiftTodos,swiftDocString,swiftMarker,@Spell oneline
|
||||
syntax region swiftComment start="/\*" end="\*/"
|
||||
\ contains=swiftTodos,swiftDocString,swiftMarker,@Spell fold
|
||||
|
||||
|
||||
" Set highlights
|
||||
highlight default link swiftTodos Todo
|
||||
highlight default link swiftDocString String
|
||||
highlight default link swiftShebang Comment
|
||||
highlight default link swiftComment Comment
|
||||
highlight default link swiftMarker Comment
|
||||
|
||||
highlight default link swiftString String
|
||||
highlight default link swiftInterpolatedWrapper Delimiter
|
||||
highlight default link swiftTypeDeclaration Delimiter
|
||||
highlight default link swiftNumber Number
|
||||
highlight default link swiftBoolean Boolean
|
||||
|
||||
highlight default link swiftOperator Operator
|
||||
highlight default link swiftCastKeyword Keyword
|
||||
highlight default link swiftKeywords Keyword
|
||||
highlight default link swiftMultiwordKeywords Keyword
|
||||
highlight default link swiftEscapedReservedWord Normal
|
||||
highlight default link swiftClosureArgument Operator
|
||||
highlight default link swiftAttributes PreProc
|
||||
highlight default link swiftConditionStatement PreProc
|
||||
highlight default link swiftStructure Structure
|
||||
highlight default link swiftType Type
|
||||
highlight default link swiftImports Include
|
||||
highlight default link swiftPreprocessor PreProc
|
||||
highlight default link swiftMethod Function
|
||||
highlight default link swiftProperty Identifier
|
||||
|
||||
highlight default link swiftDefinitionModifier Define
|
||||
highlight default link swiftConditionStatement PreProc
|
||||
highlight default link swiftAvailability Normal
|
||||
highlight default link swiftAvailabilityArg Normal
|
||||
highlight default link swiftPlatforms Keyword
|
||||
highlight default link swiftDebugIdentifier PreProc
|
||||
highlight default link swiftLineDirective PreProc
|
||||
|
||||
" Force vim to sync at least x lines. This solves the multiline comment not
|
||||
" being highlighted issue
|
||||
syn sync minlines=100
|
||||
|
||||
let b:current_syntax = "swift"
|
@ -0,0 +1,45 @@
|
||||
if exists('g:loaded_syntastic_swift_swiftlint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_swift_swiftlint_checker = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_swift_swiftlint_IsAvailable() dict
|
||||
if !executable(self.getExec())
|
||||
return 0
|
||||
endif
|
||||
|
||||
return get(g:, 'syntastic_swift_swiftlint_use_defaults', 0)
|
||||
\ || filereadable('.swiftlint.yml')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_swift_swiftlint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args': 'lint --use-script-input-files',
|
||||
\ 'fname': '' })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c: %trror: %m,' .
|
||||
\ '%f:%l:%c: %tarning: %m,' .
|
||||
\ '%f:%l: %trror: %m,' .
|
||||
\ '%f:%l: %tarning: %m'
|
||||
|
||||
let env = {
|
||||
\ 'SCRIPT_INPUT_FILE_COUNT': 1,
|
||||
\ 'SCRIPT_INPUT_FILE_0': expand('%:p'),
|
||||
\ }
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'env': env })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'swift',
|
||||
\ 'name': 'swiftlint' })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
@ -0,0 +1,44 @@
|
||||
if exists('g:loaded_syntastic_swift_swiftpm_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_swift_swiftpm_checker = 1
|
||||
|
||||
if !exists('g:syntastic_swift_swiftpm_executable')
|
||||
let g:syntastic_swift_swiftpm_executable = 'swift'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_swift_swiftpm_arguments')
|
||||
let g:syntastic_swift_swiftpm_arguments = 'build'
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_swift_swiftpm_IsAvailable() dict
|
||||
if !executable(self.getExec())
|
||||
return 0
|
||||
endif
|
||||
|
||||
return filereadable('Package.swift')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_swift_swiftpm_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'fname': '',
|
||||
\ 'args': g:syntastic_swift_swiftpm_arguments })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c: error: %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'swift',
|
||||
\ 'name': 'swiftpm',
|
||||
\ 'exec': g:syntastic_swift_swiftpm_executable })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
Reference in New Issue
Block a user