LSP Devtools

The LSP Devtools project provides a number of tools for making the the process of developing language servers easier.

Client Capability Index

Important

This accuracy of this section entirely depends on the captured capabilities data that is bundled with pytest-lsp.

Pull requests for corrections and new data welcome!

Inspired by caniuse.com this provides information on which clients support which features of the LSP Specification.

General

General client capabilities.

NotebookDocument

Capabilities for NotebookDocuments.

TextDocument

Capabilities for text document methods like completion, code actions and more.

Window

Work done progress, show document and message requests

Workspace

File operations, workspace folders and configuration

lsp-devtools

https://user-images.githubusercontent.com/2675694/273293510-e43fdc92-03dd-40c9-aaca-ddb5e526031a.png

The lsp-devtools package provides a collection of CLI utilities that help inspect and visualise the interactions between a language client and a server.

See the Getting Started guide for details.

pytest-lsp

pytest-lsp is a pytest plugin for writing end-to-end tests for language servers.

================================== test session starts ====================================
platform linux -- Python 3.11.2, pytest-7.2.0, pluggy-1.0.0
rootdir: /..., configfile: tox.ini
plugins: typeguard-2.13.3, asyncio-0.20.2, lsp-0.2.1
asyncio: mode=Mode.AUTO
collected 1 item

test_server.py F                                                                      [100%]

======================================== FAILURES =========================================
____________________________________ test_completions _____________________________________

client = <pytest_lsp.client.LanguageClient object at 0x7f38f144a690>
   ...
E       assert False

test_server.py:35: AssertionError
---------------------------- Captured window/logMessages call -----------------------------
  LOG: Suggesting item 0
  LOG: Suggesting item 1
  LOG: Suggesting item 2
  LOG: Suggesting item 3
  LOG: Suggesting item 4
  LOG: Suggesting item 5
  LOG: Suggesting item 6
  LOG: Suggesting item 7
  LOG: Suggesting item 8
  LOG: Suggesting item 9
================================ short test summary info ==================================
FAILED test_server.py::test_completions - assert False
=================================== 1 failed in 1.02s =====================================

It works by running the language server in a subprocess and communicating with it over stdio, just like a real language client. This also means pytest-lsp can be used to test language servers written in any language - not just Python.

pytest-lsp relies on pygls for its language server protocol implementation.

See the Getting Started guide for details on how to write your first test case.