You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A full-featured, well-typed, and easy-to-use Python client for the Language Server Protocol (LSP). This library provides a clean, async-first interface for interacting with language servers, supporting both local and container-based runtimes.
8
+
A production-ready, async-first Python client for the Language Server Protocol (LSP). Built for developers who need fine-grained control, container isolation, and extensibility when integrating language intelligence into their tools.
9
9
10
10
## Why lsp-client?
11
11
12
-
`lsp-client` is designed specifically for developers who need **high control**, **isolation**, and **extensibility**:
12
+
`lsp-client` is engineered for developers building **production-grade tooling** that requires precise control over language server environments:
13
13
14
-
-**🐳 Native Container Support**: Unlike other clients that focus on local process management, `lsp-client` treats containers as a first-class citizen. It handles the "magic" of mounting workspaces, translating file paths between your host and the container, and managing container lifecycles. Pre-built containers are available for all supported language servers.
15
-
-**🧩 SDK for Custom Tooling**: Instead of being a closed wrapper, this is a true SDK. Our **Modular Capability System** allows you to build custom clients by mixing and matching only the LSP features you need, or even adding your own protocol extensions seamlessly.
16
-
-**🛠️ Explicit over Implicit**: We prioritize predictable environments. While other tools might auto-download binaries, `lsp-client` gives you full control over your server environment (Local or Container), making it ideal for production-grade tools where version pinning is critical.
17
-
-**⚡ Modern Async-First Architecture**: Built from the ground up for Python 3.12+, utilizing advanced async patterns to ensure high-performance concurrent operations without blocking your main event loop.
18
-
19
-
## Features
20
-
21
-
-**🚀 Environment Agnostic**: Seamlessly switch between local processes and isolated containers.
22
-
-**🔧 Full LSP 3.17 Support**: Comprehensive implementation of the latest protocol specification.
23
-
-**🎯 Specialized Clients**: Out-of-the-box support for popular servers (Pyright, Deno, Rust-Analyzer, etc.).
-**🧩 Pluggable & Modular**: Easily extend functionality or add support for custom LSP extensions.
26
-
-**🔒 Production-Grade Reliability**: Robust error handling, automatic retries, and full type safety.
14
+
-**🐳 Container-First Architecture**: Containers as first-class citizens with workspace mounting, path translation, and lifecycle management. Pre-built images available, seamless switching between local and container environments.
15
+
-**🧩 Intelligent Capability Management**: Zero-overhead mixin system with automatic registration, negotiation, and availability checks. Only access methods for registered capabilities.
16
+
-**🎯 Complete LSP 3.17 Support**: Full specification implementation with pre-configured clients for Pyright, Rust-Analyzer, Deno, TypeScript, and Pyrefly.
17
+
-**⚡ Production-Ready & Modern**: Explicit environment control with no auto-downloads. Built with async patterns, comprehensive error handling, retries, and full type safety.
27
18
28
19
## Quick Start
29
20
30
21
### Installation
31
22
32
23
```bash
24
+
# Recommended: Use uv for modern Python dependency management
33
25
uv add lsp-client
26
+
27
+
# Or with pip
28
+
pip install lsp-client
34
29
```
35
30
36
-
### Basic Usage
31
+
### Local Language Server
32
+
33
+
The following code snippet can be run as-is, try it out:
37
34
38
35
```python
39
-
from pathlib import Path
36
+
# install pyrefly with `uv tool install pyrefly` first
40
37
import anyio
41
38
from lsp_client import Position
42
-
from lsp_client.clients.pyrightimportPyrightClient, PyrightLocalServer
39
+
from lsp_client.clients.pyreflyimportPyreflyClient
43
40
44
41
asyncdefmain():
45
-
workspace = Path.cwd()
46
-
asyncwith PyrightClient(
47
-
workspace=workspace,
48
-
server=PyrightLocalServer(),
49
-
) as client:
50
-
# Find definition of something at line 11, character 28 in a file
51
-
refs =await client.request_definition_locations(
52
-
file_path="src/main.py",
53
-
position=Position(11, 28) # line 12, character 29 (1-indexed)
| TypeScript Language Server |`lsp_client.clients.typescript`| TypeScript/JavaScript |`ghcr.io/observerw/lsp-client/typescript`|
97
+
98
+
Container images are automatically updated weekly to ensure access to the latest language server versions.
109
99
110
-
Containers are automatically updated weekly to ensure you always have the latest versions.
100
+
### Key Benefits
101
+
102
+
1.**Method Safety**: You can only call methods for capabilities you've registered. No runtime surprises from unavailable capabilities.
103
+
2.**Automatic Registration**: The mixin system automatically handles client registration, capability negotiation, and availability checks behind the scenes.
104
+
3.**Zero Boilerplate**: No manual capability checking, no complex initialization logic, no error handling for missing capabilities.
105
+
4.**Type Safety**: Full type annotations ensure you get compile-time guarantees about available methods.
106
+
5.**Composability**: Mix and match exactly the capabilities you need, creating perfectly tailored clients.
111
107
112
108
## Contributing
113
109
114
-
We welcome contributions! Please see our [Contributing Guide](docs/contribution/) for details.
110
+
We welcome contributions! Please see our [Contributing Guide](docs/contribution/) for details on:
111
+
112
+
- Adding new language server support
113
+
- Extending protocol capabilities
114
+
- Container image updates
115
+
- Development workflow
115
116
116
117
## License
117
118
@@ -121,4 +122,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
121
122
122
123
- Built on the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) specification
123
124
- Uses [lsprotocol](https://github.com/microsoft/lsprotocol) for LSP type definitions
124
-
-Inspired by [multilspy](https://github.com/microsoft/multilspy) and other LSP clients
125
+
-Architecture inspired by [multilspy](https://github.com/microsoft/multilspy) and other LSP clients
0 commit comments