Newton LSP Server Bridge

Credit

Overview

This repo provides a primary Dockerfile (with additional example standalone LSP Dockler files from lspcontainers) that packages a number of LSPs and tools into a container along with the src/ folder code. The code under src/ comes from websockets-ls and has been cleaned up and formatted to my style/asthetics as well as modified server list. The code creates a WebSocket bridge to interface with multiple Language Servers through clients via a single WebSocket connection. It supports various language servers concurrently and handles language-specific file extensions and initialization parameters.

Features

  • Utilizes vscode-jsonrpc for LSP message handling.
  • Supports multiple language servers concurrently.
  • Support for IPC and stdio communication with language servers.
  • Easy language server configuration and initialization parameter modification.
  • Error handling and logging for language server processes.
  • Automatic file URI translation between server and client paths.
  • Temporary file creation for textDocument/didOpen events.

Usage

Setup 1:
  1. Install Node.js.
  2. Run 'npm install'.
  3. Configure the desired language servers in defaultServers.js.
  4. Run the script: npm run start || start-verbose.
  5. Connect to the WebSocket server on ws://localhost:9999/<language_endpoint>.
  6. Transmit LSP messages via the WebSocket connection.
Setup 2:
  1. Install Podman.
  2. Create opt/ folder in Docker/ and add any additional programs there.
  3. Configure the desired language servers in src/defaultServers.js.
  4. Configure the start script at Docker/scripts/start.sh with abny additional env args or mount points.
  5. Run from Newton-LSP/ Docker/build.sh .
  6. Run Docker/scripts/start.sh
  7. Connect to the WebSocket server on ws://localhost:9999/<language_endpoint>.
  8. Transmit LSP messages via the WebSocket connection.

Configuration

Add or modify language server configurations in languageServers.js:

exports.servers = [
   {
       endpointName: "language_endpoint",                  // WebSocket endpoint name
       args: ['executable_path', ['arg1', 'arg2', ...]],
       connectionType: "ipc" | "stdio",                    // Communication type
       relativePath: true | false,                         // Whether to use relative paths
       serverFileNameReplacePattern: {                     // Server file name regex replacements
           from: /pattern/,
           to: "replacement"
       },
       clientFileNameReplacePattern: {                     // Client file name regex replacements
           from: /pattern/,
           to: "replacement"
       }
   },
   ...
];
Description
Newton LSP Server Bridge
Readme GPL-2.0 1.8 MiB
Languages
Dockerfile 52.5%
JavaScript 30%
Shell 17.5%