Skip to main content

sansio-lsp-client

This is an implementation of the client side of the langserver (LSP) protocol, useful for embedding easily in your editor. It is used in Porcupine, and will soon be used in Biscuit too.

The "sans io" part of the name means "without IO". It means that this library doesn't do IO, and you do it instead. Specifically:

  • You start a langserver process
  • You read data from the stdout of the langserver process
  • You feed the data to this library
  • This library returns data to be written to the stdin of the langserver process
  • You write the data to the stdin of the langserver process.

This way, this library is very flexible. It assumes nothing about how IO works, so you can use it with threads, without threads, with sync code, with async code, or with any other kind of IO thing.

Usage

Unfortunately, there isn't much documentation. Hopefully someone will write some docs eventually :)

If you want to add langserver support to a text editor, you could look at Porcupine's langserver plugin to get started. Porcupine is MIT licensed, so you can use its code in your projects as long as you credit Porcupine accordingly. You can also look at this project's tests, which are simple in principle, but kind of messy in practice.

Maintenance Status

Currently (2024) there are two maintainers (Akuli and PurpleMyst) who merge and review pull requests. Also, the project cannot become totally broken, because Akuli uses Porcupine almost every day, and langserver support is an essential part of Porcupine.

New features are usually added by someone else than the two maintainers. We recommend just adding what you need for your use case and making a pull request.

Developing

$ git clone https://github.com/PurpleMyst/sansio-lsp-client
$ cd sansio-lsp-client
$ python3 -m venv env
$ source env/bin/activate
(env)$ pip install --upgrade pip
(env)$ pip install poetry
(env)$ poetry install

Most tests don't work on Windows, but GitHub Actions runs tests of all pull requests and uploads coverage files from them. TODO: add instructions for looking at coverage files on Windows

To run tests, first download the langservers you need. You can mostly read .github/workflows/test.yml, but the Go langserver is a bit of a gotcha. You will need to install go from https://golang.org/, because the one from sudo apt install golang is too old. Extract it inside where you cloned sansio-lsp-client so that you get an executable named sansio-lsp-client/go/bin/go.

$ tar xf ~/Downloads/go1.16.5.linux-amd64.tar.gz

Once you have installed all langservers you want, you can run the tests:

(env)$ PATH="$PATH:$(pwd)/go/bin" poetry run pytest -v

Release files for sansio-lsp-client 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sansio-lsp-client 0.13.0
File Size Uploaded
sansio_lsp_client-0.13.0.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sansio-lsp-client 0.13.0
File Interpreter ABI Platform
sansio_lsp_client-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size:31.4 kB

Release files / sansio_lsp_client-0.13.0.tar.gz

Download URL sansio_lsp_client-0.13.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4409da067017cfd668769ccc4b1ece6e5d2614344069b85c1c8ca90994720077
BLAKE2b-256 checksum
How to use checksums
bd49be68e7eef46f382bcdffde57a9596622be29ec2750017360cba8163f4911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release files / sansio_lsp_client-0.13.0-py3-none-any.whl

Download URL sansio_lsp_client-0.13.0-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36e838f68c4c34d7378bc3c6d51cbe8c45a92a284fddc90d3de785269221d5eb
BLAKE2b-256 checksum
How to use checksums
efce686f94cd12b8ea19248027b1f035ef5d0d294b41159ece26f72e2612611f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page