Skip to main content

A pythonic generic language server (pronounced like 'pie glass')

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygls-2.0.1.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygls-2.0.1-py3-none-any.whl (69.5 kB view details)

Uploaded Python 3

File details

Details for the file pygls-2.0.1.tar.gz.

File metadata

  • Download URL: pygls-2.0.1.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for pygls-2.0.1.tar.gz
Algorithm Hash digest
SHA256 2f774a669fbe2ece977d302786f01f9b0c5df7d0204ea0fa371ecb08288d6b86
MD5 3057398ee8a5ae3b72201b0382197b3d
BLAKE2b-256 1b94cce3560f6c7296be43bd67ba342f8972b8adddfe407b62b25d1fb90c514b

See more details on using hashes here.

File details

Details for the file pygls-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pygls-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 69.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for pygls-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d29748042cea5bedc98285eb3e2c0c60bf3fc73786319519001bf72bbe8f36cc
MD5 39e93b8f91be10ff77eb652fd150c294
BLAKE2b-256 488bd0d7e51f928ec6e555c943f7c07a712b992e9cf061d52cbf37fbf8622c05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page