pygls

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

48 个版本 Python >=3.9
Open Law Library <info@openlawlib.org>
安装
pip install pygls
poetry add pygls
pipenv install pygls
conda install pygls
描述

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

版本列表
2.1.1 2026-03-25
2.1.0 2026-03-19
2.0.1 2026-01-26
2.0.0 2025-10-17
2.0.0a6 2025-07-18
2.0.0a5 2025-07-14
2.0.0a4 2025-06-05
2.0.0a3 2025-05-18
2.0.0a2 2024-11-04
2.0.0a1 2024-08-24
1.3.1 2024-03-26
1.3.0 2024-01-29
1.2.1 2023-11-30
1.2.0 2023-11-18
1.1.2 2023-10-28
1.1.1 2023-10-06
1.1.0 2023-10-02
1.0.2 2023-05-16
1.0.1 2023-02-16
1.0.0 2022-12-03
1.0.0a3 2022-11-09
1.0.0a2 2022-11-02
1.0.0a0 2022-10-17
0.13.1 2022-12-01
0.13.0 2022-11-03
0.12.4 2022-10-25
0.12.3 2022-10-24
0.12.2 2022-09-27
0.12.1 2022-08-02
0.12 2022-07-08
0.11.3 2021-11-06
0.11.2 2021-07-23
0.11.1 2021-06-21
0.11.0 2021-06-18
0.10.3 2021-05-05
0.10.2 2021-03-25
0.10.1 2021-03-17
0.10.0 2021-03-16
0.9.1 2020-09-29
0.9.0 2020-04-20
0.8.1 2019-09-05
0.8.0 2019-05-13
0.7.4 2019-03-21
0.7.3 2019-01-30
0.7.2 2018-12-28
0.7.1 2018-12-28
0.7.0 2018-12-21
0.12rc1 2022-07-05