Newton LSP Server Bridge
Credit
Overview
This repo provides a primary Dockerfile with additional examples that are seperate in form and structure but useful for reference.
LSP Docker files under reference-servers are from lspcontainersproject that packages a number of LSPs.
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. (I.E NO structural changes)
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-jsonrpcfor 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/didOpenevents.
Usage
Option 1:
- Install Podman.
- Create
opt/folder inDocker/and add any additional programs (lsps) there. - Configure the desired language servers in
src/defaultServers.js. - Configure the start script at
Docker/scripts/start.shwith any additional env args or mount points. - Run from
Newton-LSP/Docker/build.sh. - Run
Docker/scripts/start.sh - Connect to the WebSocket server on
ws://localhost:9999/<language_endpoint>. - Transmit LSP messages via the WebSocket connection.
Option 2:
- Install Node.js.
- Run 'npm install'.
- Configure the desired language servers in
defaultServers.js. - Run the script:
npm run start || start-verbose. - Connect to the WebSocket server on
ws://localhost:9999/<language_endpoint>. - 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"
}
},
...
];
Languages
Dockerfile
52%
JavaScript
29.6%
Shell
18.4%