All Projects → RLovelett → Vscode Swift

RLovelett / Vscode Swift

Licence: mit
An extension for VS Code which provides support for the Swift language.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vscode Swift

Langserver Swift
A Swift implementation of the open Language Server Protocol.
Stars: ✭ 171 (+29.55%)
Mutual labels:  vscode, vscode-extension, language-server
Vshaxe
Haxe Support for Visual Studio Code
Stars: ✭ 234 (+77.27%)
Mutual labels:  vscode, vscode-extension, language-server
Vscode Intelephense
PHP intellisense for Visual Studio Code
Stars: ✭ 872 (+560.61%)
Mutual labels:  vscode, vscode-extension, language-server
Vscode Elastic
Elasticsearch for VSCode
Stars: ✭ 130 (-1.52%)
Mutual labels:  vscode, vscode-extension
Markdown Toc
MarkdownTOC(Table Of Contents) Plugin for Visual Studio Code.
Stars: ✭ 130 (-1.52%)
Mutual labels:  vscode, vscode-extension
Coddx Alpha
Coddx - a collection of tools that help developers program efficiently. One of the features is generating multiple files from templates quickly.
Stars: ✭ 132 (+0%)
Mutual labels:  vscode, vscode-extension
Vscode Js Annotations
Javascript / Typescript Parameter Annotations for Visual Studio Code
Stars: ✭ 110 (-16.67%)
Mutual labels:  vscode, vscode-extension
Ffi Navigator
Stars: ✭ 122 (-7.58%)
Mutual labels:  vscode-extension, language-server
Vscode Postgres
PostgreSQL extension for vscode providing explorer, highlighting, diagnostics, and intellisense
Stars: ✭ 117 (-11.36%)
Mutual labels:  vscode, vscode-extension
Vscode Language Pascal
Pascal language extension for Visual Studio Code
Stars: ✭ 117 (-11.36%)
Mutual labels:  vscode, vscode-extension
Vscode Neovim
VSCode Neovim Integration
Stars: ✭ 2,474 (+1774.24%)
Mutual labels:  vscode, vscode-extension
Vscode Azure Blockchain Ethereum
Blockchain extension for VS Code
Stars: ✭ 111 (-15.91%)
Mutual labels:  vscode, vscode-extension
I18n Ally
🌍 All in one i18n extension for VS Code
Stars: ✭ 1,931 (+1362.88%)
Mutual labels:  vscode, vscode-extension
Vscode Go
Go extension for Visual Studio Code
Stars: ✭ 2,268 (+1618.18%)
Mutual labels:  vscode, vscode-extension
Vscode
Unibeautify for VSCode
Stars: ✭ 110 (-16.67%)
Mutual labels:  vscode, vscode-extension
Vscode Apielements
VSCode extensions for API Elements (aka: API Blueprint and Swagger)
Stars: ✭ 117 (-11.36%)
Mutual labels:  vscode, vscode-extension
Advpl Vscode
Suporte para Advpl no VsCode
Stars: ✭ 132 (+0%)
Mutual labels:  vscode, vscode-extension
Quicktype Vscode
VS Code extension to convert JSON to TypeScript, C#, Go, and many more
Stars: ✭ 131 (-0.76%)
Mutual labels:  vscode, vscode-extension
Doxdocgen
Generate doxygen documentation from source code in VS Code
Stars: ✭ 127 (-3.79%)
Mutual labels:  vscode, vscode-extension
Flowmaker
flowmaker: JS to SVG flowchart generation extension for Vscode in realtime written in typescript and also download the SVG through local node server. Extension:
Stars: ✭ 108 (-18.18%)
Mutual labels:  vscode, vscode-extension

Swift for Visual Studio Code

This extension adds rich language support for the Swift language to VS Code. These features are provided by the Swift framework itself through SourceKit and a Swift Language Server implementation.

Currently the extension provides rudimentary support for:

  • Completion lists
  • Symbol resolution

Future support for:

  • Document Highlights: highlights all 'equal' symbols in a Swift document.
  • Hover: provides hover information for a symbol selected in a Swift document.
  • Signature Help: provides signature help for a symbol selected in a Swift document.
  • Find References: find all project-wide references for a symbol selected in a Swift document.
  • List Workspace Symbols: list all project-wide symbols.
  • CodeLens: compute CodeLens statistics for a given Swift document.
  • Rename: project-wide rename of a symbol.
  • Debugger
  • Swift Package Manger

Features

Completion Lists

Use completion lists to find out about available standard library types and function signatures.

Struct Def

Do the same for your own custom types. Including documentation comments.

Struct Docs

Requirements

This extension requires Swift to be installed on your system. It also requires a Swift language server be installed as well. By default the extension looks for the language server to be installed at /usr/local/bin/LanguageServer (though this behavior is configurable).

Swift

  • Swift Open Source swift-DEVELOPMENT-SNAPSHOT-2016-12-01-a toolchain (Minimum REQUIRED for latest release)

macOS

  • macOS 10.11.6 (El Capitan) or higher
  • Xcode Version 8.2 beta (8C30a) or higher using one of the above toolchains (Recommended)

Linux

A few remarks about Linux support

The language server that drives this extension depends on SourceKit to be available with the Swift toolchain. Unfortunately, at this time that means that Linux support is not really possible because SourceKit is not built by default on Linux.

Of course it is possible to build SourceKit for Linux. However, doing so is beyond the scope of this project.

All of the dependencies of the language server, at least ostensibly, support Linux. So there should be little preventing Linux support beyond SourceKit being available on the platform.

I want to stress: I hope this will not be the long-term answer/solution. In fact running on Linux was the whole reason why I started this extension.

Extension Settings

  • LanguageServer path

Known Issues

  • Does not run on Linux

Debug and Development

The extension itself relies on a language server to interact with it. This server has been developed to work with Visual Studio Code.

An example workflow for interactively debugging the language server while using it with the Visual Stuio Code client is provided in this section. The instructions are devided into two sections. The first section explains how to generate and configure an Xcode project for debugging. The second section explains how to configure the Visual Studio Code plugin to use the debug executable.

Xcode (e.g., langserver-swift)

In the directory containing the clone of the language server use SwiftPM to generate an Xcode project.

% git clone https://github.com/RLovelett/langserver-swift.git
% cd langserver-swift
% swift package generate-xcodeproj --xcconfig-overrides settings.xcconfig

Since the language server client, e.g., VSCode, will actually launch the language server LLDB needs to be told to wait for the application to launch. This can be configured in Xcode after opening the generated project in Xcode. See the screenshot below.

screen shot 2017-02-22 at 8 55 57 am

The next step is to build the executable and launch LLDB. Both of these steps can be performed by going to "Product > Run" or the keyboard shortcut ⌘R. After building completes, Xcode should report something like "Waiting to attach to LanguageServer : LanguageServer".

screen shot 2017-02-22 at 9 40 33 am

One final step is to determine the TARGET_BUILD_DIR. This is used to tell the VSCode extension in the next section where the debug language server is located.

From a terminal whose current working directory contains the Xcode project previously generated by SwiftPM you can get this information from xcodebuild.

% xcodebuild -project langserver-swift.xcodeproj -target "LanguageServer" -showBuildSettings | grep "TARGET_BUILD_DIR"
   TARGET_BUILD_DIR = /Users/ryan/Library/Developer/Xcode/DerivedData/langserver-swift-gellhgzzpradfqbgjnbtkvzjqymv/Build/Products/Debug

Take note of this value it will be used later.

VSCode (e.g., vscode-swift)

Open the directory containing the clone of the Visual Studio Code extension in Visual Studio Code.

% git clone https://github.com/RLovelett/vscode-swift.git
% code .

Start the TypeScript compiler or the build task (e.g., ⇧⌘B or Tasks: Run Build Task).

Now open src/extension.ts and provide the value of TARGET_BUILD_DIR for the debug executable. The change should be similar to the patch that follows.

diff --git a/src/extension.ts b/src/extension.ts
index b5ad751..7970ae1 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -13,7 +13,7 @@ export function activate(context: ExtensionContext) {
         .get("languageServerPath", "/usr/local/bin/LanguageServer");

     let run: Executable = { command: executableCommand };
-    let debug: Executable = run;
+    let debug: Executable = { command: "${TARGET_BUILD_DIR}/LanguageServer" };
     let serverOptions: ServerOptions = {
         run: run,
         debug: debug

NOTE: Make sure the ${TARGET_BUILD_DIR} is populated with the value you generated in the Xcode section. It is not an environment variable so that will not be evaluated.

Once this is complete you should be able to open the VSCode debugger and and select Launch Extension. This should start both the language server (Xcode/Swift) and the extension (VScode/TypeScript) in debug mode.

Caveats

  1. As noted above you might not be able to capture all the commands upon the language server initially starting up. The current hypothesis is that it takes a little bit of time for LLDB (the Swift debugger) to actually attach to the running process so a few instructions are missed.

One recommendation is to put a break-point in handle.swift as this is likely where the server is getting into to trouble.

  1. Messages are logged to the Console.app using the me.lovelett.langserver-swift sub-system. One place to look the raw language server JSON-RPC messages is there.

Release Notes

For detailed release notes see: Releases

0.1.0

0.0.5

  • Completions use snippet formatting for placeholders, allows the cursor to tab between placeholders
  • Completions index against all swift files in the workspace
  • Bug fixes

0.0.3

  • Allow configuring sourceKitten install location

0.0.2

Preview release of the extension

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].