Skip to content

A language server proxy that provides file synchronization and code execution

License

Notifications You must be signed in to change notification settings

MozarellaMan/rust-lsp-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Language Server Proxy

This program aims to act as an easy-to-use, remote, middleman between any Language Server and your own Language Server compliant client.

Your code and language server are installed on your machine, enabling any mobile app or consumer of the proxy to immediately support your machine's toolchain.

Language Server notifications sent to the proxy (textDocument/didChange and workspace/didCreateFiles) are intercepted by the proxy to provide file synchronization between client edits to the proxy's files.

Endpoints in the proxy can be used to run and stop the running of code, via a websocket, which is not provided by the Language Server Protocol (code/run/{source path})

Made with Rust, Actix Web, and Tokio.

Have a look at the Architecture document for an overview of the code.

Features

  • Remote file synchronization
  • Websocket connection to Language Server Protocol compliant server
    • Currently, only the Java JDT language server has a pre-configured run command in the proxy, however it is possible to set a custom command via command line argument to run any language server of your choosing
  • Remote code compilation and execution
  • Remote input to running code via proxy endpoint
  • Proxy is thin and lightweight in resource usage

Currently Unimplemented

  • Code execution for common languages, not just java, (some sort of generification needed)
  • Security (this has mainly been targeted at private usage)

Example Client

The app shown above connects to the proxy; uses communication with the language server to provide language features such as code diagnostics (warning about resource leak) and uses the proxy to provide file synchronisation and the ability to run and send input to the running source code remotely. This is just an example, a different client consuming this proxy can look totally different or run on a different device.

How to use

Running

Program Dependencies

  • a language server
    • Currently only the Eclipse Java Language Server is officially supported
      • At least Java 11 to run the server
      • You could build it yourself, or download the latest (at least 0.60, but old may work) binary from their releases (recommended)
  • a Language Server Proxy binary (you can find latest releases here)
    • recommended instead of building as it's quicker
    • (recommended) extract and run .exe in a terminal OR add unzipped folder to PATH
    • Linux and Windows binaries available, for Mac you will need to build it yourself for now. (Instructions below)

Program Instructions

USAGE:
    lsp_proxy.exe [OPTIONS] --codebase-path --lang-server-path  --language

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -c, --codebase-path
    -s, --lang-server-path
    -d, --custom-lang-server-cmd

    -l, --language
    -p, --port [default: 8001]
  • codebase-path is the path to the directory you want the language server to run on
  • lang-server-path is the path to the language server binary (currently only Java supported)
  • language is a value that tells the proxy what language is being used (refer to this table)
  • port is the port that the proxy should listen for requests on
  • custom-lang-server-cmd allows you to specify a custom command for the proxy to run while in the directory of your language server (allows the use of language servers not officially implemented by me for the proxy)

Building

Build Dependencies

  • Rust (this will also install Cargo, the Rust build tool)
    • At least v1.46

Build Instructions

  • cargo run will build and run the proxy in debug mode
  • cargo run -- will build and run the proxy in debug mode, with program arguments added in after the -- (e.g. cargo run -- -h)
  • cargo test will run the test suite
  • cargo build --release will build a binary in release mode that you can find in /target

About

A language server proxy that provides file synchronization and code execution

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages