Well, it’s finally here… at least in a very early beta stage: Swift for Visual Studio Code (aka vscode-swift). This is my new code editor experience for Visual Studio Code. The project is actually made up of multiple projects:
- json-swift: a cross-platform JSON parsing library written completely in Swift.
- swift-lsp: an implementation of the Language Server Protocol put out by Microsoft. This allows anyone to use this project to write a language server for any language they want. It essentially creates an interface to talk between any code editor that implements the LSP and your language server.
- vscode-swift: This is simply the host extension that handles all of the magic. This is the least interesting part, but will be the project you use to actually get all of this stuff working within VS Code.
- swift-langsrv: This is the language server for Swift. Currently it is backed by SourceKit, though this is going to have to change or some SourceKit reckoning will need to happen.
First things first, this is still very early in the development cycle. What I have working right now is:
- Better syntax highlighting
- Basic snippets
- Code completion, which should work for all imported modules as well
- Linking to Swift bugs in your comments:
That will be a hyperlink in VS Code to: https://bugs.swift.org/browse/SR-2688
There has only been ad-hoc, smoke testing done as of right now, so if you want to try it out, you can, but don’t get mad at me if it works just as well as Xcode.
Getting things to work on macOS is the as simple as downloading the extension from the marketplace. The Swift Language Server binaries are included for you. The only external requirement is that you need to have Swift 3.1 installed in one of the standard locations. If it is not, you can update the path in your
This will happen soon… I have this working on local builds, but it requires a bunch of hackery because SourceKit isn’t build with the Linux builds of Swift 3.
Windows (Linux Subsystem)
Similar story as Linux above but there are additional complexities here, including the reliability of
swift build itself. As such, this is not supported, but I will post some instructions on how to do this later.
Go try it out! https://marketplace.visualstudio.com/items?itemName=kiadstudios.vscode-swift.
If you find bugs, which I’m sure there are still many as it’s early in the release cycle, please log them here: vscode-swift. Also, if you’re on macOS 10.12, you can find log data in the Console under the subsystem
com.kiadstudios. That should be helpful information to attach.