pygls: The Generic Language Server Framework
pygls (pronounced like "pie glass") is a pythonic generic implementation of the Language Server Protocol for use as a foundation for writing your own Language Servers in just a few lines of code.
Quickstart
from pygls.server import LanguageServer
from lsprotocol.types import (
TEXT_DOCUMENT_COMPLETION,
CompletionItem,
CompletionList,
CompletionParams,
)
server = LanguageServer("example-server", "v0.1")
@server.feature(TEXT_DOCUMENT_COMPLETION)
def completions(params: CompletionParams):
items = []
document = server.workspace.get_document(params.text_document.uri)
current_line = document.lines[params.position.line].strip()
if current_line.endswith("hello."):
items = [
CompletionItem(label="world"),
CompletionItem(label="friend"),
]
return CompletionList(is_incomplete=False, items=items)
server.start_io()
Which might look something like this when you trigger autocompletion in your editor:
Docs and Tutorial
The full documentation and a tutorial are available at https://pygls.readthedocs.io/en/latest/.
Projects based on pygls
We keep a table of all known pygls implementations. Please submit a Pull Request with your own or any that you find are missing.
Alternatives
The main alternative to pygls is Microsoft's NodeJS-based Generic Language Server Framework. Being from Microsoft it is focussed on extending VSCode, although in theory it could be used to support any editor. So this is where pygls might be a better choice if you want to support more editors, as pygls is not focussed around VSCode.
There are also other Language Servers with "general" in their descriptons, or at least intentions. They are however only general in the sense of having powerful configuration. They achieve generality in so much as configuration is able to, as opposed to what programming (in pygls' case) can achieve.
- https://github.com/iamcco/diagnostic-languageserver
- https://github.com/mattn/efm-langserver
- https://github.com/jose-elias-alvarez/null-ls.nvim (Neovim only)
Tests
poetry install --all-extraspoetry run testpoetry run test-pyodide
Contributing
Your contributions to pygls are most welcome ❤️ Please review the Contributing and Code of Conduct documents for how to get started.
Donating
Open Law Library is a 501(c)(3) tax exempt organization. Help us maintain our open source projects and open the law to all with sponsorship.
Supporters
We would like to give special thanks to the following supporters:
License
Apache-2.0
Metadata
Release files for pygls 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pygls-1.1.0.tar.gz | 45.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygls-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.4 kB
Release files / pygls-1.1.0.tar.gz
| Download URL | pygls-1.1.0.tar.gz |
|---|---|
| Size | 45.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb19b818039d3d705ec8adbcdf5809a93af925f30cd7a3f3b7573479079ba00e
|
|
BLAKE2b-256 checksum How to use checksums |
101a4994d487a7295a7c834a81003b83b00b26086dbd3747699ed3eb20e73fcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.12.0rc3 Linux/6.5.4-403.asahi.fc40.aarch64+16k
|
Release files / pygls-1.1.0-py3-none-any.whl
| Download URL | pygls-1.1.0-py3-none-any.whl |
|---|---|
| Size | 53.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70acb6fe0df1c8a17b7ce08daa0afdb4aedc6913a6a6696003e1434fda80a06e
|
|
BLAKE2b-256 checksum How to use checksums |
8858b1430d34a6133eaf11a1927a15bc709cf8c8420c6fd7197da1bed25fe54a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.12.0rc3 Linux/6.5.4-403.asahi.fc40.aarch64+16k
|
Security for pygls 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.