Skip to main content

PyPI Version !pyversions license Documentation Status

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.lsp.server import LanguageServer
from lsprotocol import types

server = LanguageServer("example-server", "v0.1")

@server.feature(types.TEXT_DOCUMENT_COMPLETION)
def completions(params: types.CompletionParams):
    items = []
    document = server.workspace.get_text_document(params.text_document.uri)
    current_line = document.lines[params.position.line].strip()
    if current_line.endswith("hello."):
        items = [
            types.CompletionItem(label="world"),
            types.CompletionItem(label="friend"),
        ]
    return types.CompletionList(is_incomplete=False, items=items)

server.start_io()

Which might look something like this when you trigger autocompletion in your editor:

completions

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.

Tests

All Pygls sub-tasks require the uv: https://docs.astral.sh/uv/getting-started/installation

  • uv run --all-extras poe test
  • uv run --all-extras poe 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 2.1.1

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

Source distribution (sdist)

Source distribution for pygls 2.1.1
File Size Uploaded
pygls-2.1.1.tar.gz 55.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygls 2.1.1
File Interpreter ABI Platform
pygls-2.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 124.1 kB

Release files / pygls-2.1.1.tar.gz

Download URL pygls-2.1.1.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1da03ba9053201bb337dcdd8d121df70feb2a91e1a0dcc74de5da79755b1a201
BLAKE2b-256 checksum
How to use checksums
da2e7bbe061d175c0baddde8fc9edb908a4c31ba5d9165b8c68e3439c3a9f138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release files / pygls-2.1.1-py3-none-any.whl

Download URL pygls-2.1.1-py3-none-any.whl
Size 69.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
510a6dea2476177230c7d851125e5948efdf3fdb9ebfd8543fc434972f8faed4
BLAKE2b-256 checksum
How to use checksums
fd1a208293b6c350f5abea6941d5606080d4a492644052504f5312e5de30a902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

Release history Release notifications | RSS feed

This release

2.1.1 This release

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.12.4

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.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