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

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 Poetry poe plugin: https://github.com/nat-n/poethepoet

  • poetry install --all-extras
  • poetry run poe test
  • poetry run 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-1.3.1.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

pygls-1.3.1-py3-none-any.whl (56.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygls-1.3.1.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.5.0-1016-azure

File hashes

Hashes for pygls-1.3.1.tar.gz
Algorithm Hash digest
SHA256 140edceefa0da0e9b3c533547c892a42a7d2fd9217ae848c330c53d266a55018
MD5 aed9156986352710d416de87022d1137
BLAKE2b-256 86b941d173dad9eaa9db9c785a85671fc3d68961f08d67706dc2e79011e10b5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygls-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.5.0-1016-azure

File hashes

Hashes for pygls-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e00f11efc56321bdeb6eac04f6d86131f654c7d49124344a9ebb968da3dd91e
MD5 b5d205aa1363104b1eb60880741c8557
BLAKE2b-256 1119b74a10dd24548e96e8c80226cbacb28b021bc3a168a7d2709fb0d0185348

See more details on using hashes here.

Supported by

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