All Projects → RLovelett → Langserver Swift

RLovelett / Langserver Swift

Licence: apache-2.0
A Swift implementation of the open Language Server Protocol.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Langserver Swift

Vscode Intelephense
PHP intellisense for Visual Studio Code
Stars: ✭ 872 (+409.94%)
Mutual labels:  vscode, vscode-extension, language-server-protocol, language-server
Monaco Languageclient
NPM module to connect Monaco editor with language servers
Stars: ✭ 419 (+145.03%)
Mutual labels:  vscode, language-server-protocol, language-server
Elm Language Client Vscode
Improving your Elm experience since 2019
Stars: ✭ 162 (-5.26%)
Mutual labels:  vscode, language-server-protocol, language-server
Vshaxe
Haxe Support for Visual Studio Code
Stars: ✭ 234 (+36.84%)
Mutual labels:  vscode, vscode-extension, language-server
Vscode Swift
An extension for VS Code which provides support for the Swift language.
Stars: ✭ 132 (-22.81%)
Mutual labels:  vscode, vscode-extension, language-server
Vscode
Connect to MongoDB and Atlas and directly from your VS Code environment, navigate your databases and collections, inspect your schema and use playgrounds to prototype queries and aggregations.
Stars: ✭ 161 (-5.85%)
Mutual labels:  vscode, vscode-extension
Browser Preview
🎢Preview html file in your default browser
Stars: ✭ 148 (-13.45%)
Mutual labels:  vscode, vscode-extension
Vscode Vite
One step faster for Vite in VS Code ⚡️
Stars: ✭ 168 (-1.75%)
Mutual labels:  vscode, vscode-extension
Vscode Kotlin
Kotlin language support for VS Code
Stars: ✭ 161 (-5.85%)
Mutual labels:  vscode, vscode-extension
Latex Utilities
An add-on to LaTeX Workshop that provides some features that go beyond the bare essentials
Stars: ✭ 142 (-16.96%)
Mutual labels:  vscode, vscode-extension
Metago
MetaGo provides fast cursor movement/selection for keyboard focused users in vscode
Stars: ✭ 151 (-11.7%)
Mutual labels:  vscode, vscode-extension
Nim
Streamline Your Node.js Debugging Workflow with Chromium (Chrome, Edge, More) DevTools.
Stars: ✭ 168 (-1.75%)
Mutual labels:  vscode, vscode-extension
Vscode Gist
vscode extension for quick gists
Stars: ✭ 146 (-14.62%)
Mutual labels:  vscode, vscode-extension
Omi Snippets
🔖Visual Studio Code Syntax Highlighting For Single File React And Omi Components - 编写React和Omi单文件组件的VSC语法高亮插件
Stars: ✭ 149 (-12.87%)
Mutual labels:  vscode, vscode-extension
Vsnotes
Simple VS Code extension for plain text note taking.
Stars: ✭ 146 (-14.62%)
Mutual labels:  vscode, vscode-extension
Vscodethemes
Themes for Visual Studio Code
Stars: ✭ 155 (-9.36%)
Mutual labels:  vscode, vscode-extension
Dance
Make your cursors dance with Kakoune-like keybindings for VS Code.
Stars: ✭ 157 (-8.19%)
Mutual labels:  vscode, vscode-extension
Vala Language Server
Code Intelligence for Vala & Genie
Stars: ✭ 156 (-8.77%)
Mutual labels:  vscode, language-server
Sublimetext Sqltools
SQLTools for Sublime Text 3
Stars: ✭ 166 (-2.92%)
Mutual labels:  vscode, vscode-extension
Git History
Quickly browse the history of a file from any git repository
Stars: ✭ 12,676 (+7312.87%)
Mutual labels:  vscode, vscode-extension

Swift Language Server

macOS Linux Apache 2 Build Status Join the chat at https://gitter.im/langserver-swift

Overview

A Swift implementation of the open Language Server Protocol. The Language Server protocol is used between a tool (the client) and a language smartness provider (the server) to integrate features like auto complete, goto definition, find all references and alike into the tool.

Currently this implementation is used by Swift for Visual Studio Code.

Prerequisites

Swift

  • Swift version 4.1.0
  • The toolchain that comes with Xcode Version 9.3 (9E145) (Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1))

macOS

  • macOS 10.12 (Sierra) or higher

Linux

  • Coming Soon

Build

% cd <path-to-clone>
% make debug

or with Xcode

% cd <path-to-clone>
% make xcodeproj

Test

% cd <path-to-clone>
% make test

Debug and Development

The language server itself relies on a language server client to interact with it. This server has been developed to work with Visual Studio Code. Though it should be noted that any client that implements the protocol should work and is thusly supported.

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 this repository use SwiftPM to generate an Xcode project.

% git clone https://github.com/RLovelett/langserver-swift.git
% cd langserver-swift
% make xcodeproj

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

Or using make:

% make print_target_build_dir

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.
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].