lsp_servers
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AstroServer anyenv.lsp_servers._servers.js_ts_lsps Astro language server with TypeScript SDK detection. |
||
| BiomeServer anyenv.lsp_servers._servers.js_ts_lsps Biome linter/formatter with JSON diagnostic parsing. |
||
| CLIDiagnosticConfig anyenv.lsp_servers._base CLI configuration for running diagnostics without full LSP. |
||
| CargoInstall anyenv.lsp_servers._base Install via cargo install. |
||
| CommandExecutor anyenv.lsp_servers._runner Protocol for command execution. |
||
| CommandResult anyenv.lsp_servers._runner Protocol for command execution results. |
||
| Diagnostic anyenv.lsp_servers._base A single diagnostic message from a tool. |
||
| DiagnosticRunner anyenv.lsp_servers._runner Run diagnostics using CLI tools. |
||
| DiagnosticsResult anyenv.lsp_servers._base Result of running diagnostics. |
||
| DotnetInstall anyenv.lsp_servers._base Install via dotnet tool install. |
||
| GemInstall anyenv.lsp_servers._base Install via gem install. |
||
| GitHubRelease anyenv.lsp_servers._base Download binary from GitHub releases. |
||
| GoInstall anyenv.lsp_servers._base Install via go install. |
||
| GoplsServer anyenv.lsp_servers._servers.go_lsps Go language server with go.work priority. |
||
| LSPServerInfo anyenv.lsp_servers._base Static configuration for an LSP server. |
||
| LSPServerRegistry anyenv.lsp_servers._registry Registry for managing LSP server configurations. |
||
| MypyServer anyenv.lsp_servers._servers.python_lsps Mypy with JSON diagnostic parsing. |
||
| NpmInstall anyenv.lsp_servers._base Install via npm/bun/pnpm. |
||
| OxlintServer anyenv.lsp_servers._servers.js_ts_lsps Oxlint (oxc) linter with JSON diagnostic parsing. |
||
| PyreflyServer anyenv.lsp_servers._servers.python_lsps Pyrefly (Meta) type checker with JSON diagnostic parsing. |
||
| PyrightServer anyenv.lsp_servers._servers.python_lsps Pyright with virtualenv detection and JSON diagnostic parsing. |
||
| RootDetection anyenv.lsp_servers._base How to detect project root for LSP. |
||
| RustAnalyzerServer anyenv.lsp_servers._servers.rust_lsps Rust analyzer with workspace detection. |
||
| SimpleCommandResult anyenv.lsp_servers._runner Simple implementation of CommandResult. |
||
| TyServer anyenv.lsp_servers._servers.python_lsps Ty (Astral) type checker with GitLab JSON diagnostic parsing. |
||
| TypeScriptServer anyenv.lsp_servers._servers.js_ts_lsps TypeScript language server with tsserver path detection. |
||
| ZubanServer anyenv.lsp_servers._servers.python_lsps Zuban type checker with mypy-compatible text output parsing. |
🛈 DocStrings¶
LSP server configurations for various programming languages.
AstroServer
dataclass
¶
Bases: LSPServerInfo
Astro language server with TypeScript SDK detection.
Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
resolve_initialization
async
¶
Detect TypeScript SDK path for Astro.
Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
CLIDiagnosticConfig
dataclass
¶
CLI configuration for running diagnostics without full LSP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Command to run (may differ from LSP command) |
required |
args
|
list[str]
|
Arguments with {files} placeholder for file paths |
required |
output_format
|
Literal['json', 'text']
|
Expected output format |
'json'
|
Source code in src/anyenv/lsp_servers/_base.py
CargoInstall
dataclass
¶
CommandExecutor
¶
Bases: Protocol
Protocol for command execution.
Source code in src/anyenv/lsp_servers/_runner.py
__call__
async
¶
__call__(command: str) -> CommandResult
CommandResult
¶
Bases: Protocol
Protocol for command execution results.
Source code in src/anyenv/lsp_servers/_runner.py
Diagnostic
dataclass
¶
A single diagnostic message from a tool.
Source code in src/anyenv/lsp_servers/_base.py
DiagnosticRunner
¶
Run diagnostics using CLI tools.
Works with any command executor (local subprocess, Docker, SSH, etc.) to run CLI diagnostic tools and parse their output.
Source code in src/anyenv/lsp_servers/_runner.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
__init__
¶
__init__(executor: CommandExecutor | None = None) -> None
Initialize with an optional command executor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executor
|
CommandExecutor | None
|
Callable to execute commands. Defaults to local subprocess. |
None
|
Source code in src/anyenv/lsp_servers/_runner.py
get_server
¶
get_server(server_id: str) -> LSPServerInfo | None
get_servers_for_file
¶
get_servers_for_file(path: str) -> list[LSPServerInfo]
Get all servers that can handle a file.
register
¶
register(server: LSPServerInfo) -> None
register_defaults
¶
Register all default servers with CLI diagnostic support.
Source code in src/anyenv/lsp_servers/_runner.py
run
async
¶
run(server: LSPServerInfo | str, files: list[str]) -> DiagnosticsResult
Run diagnostics using a specific server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server
|
LSPServerInfo | str
|
Server instance or server ID |
required |
files
|
list[str]
|
File paths to check |
required |
Returns:
| Type | Description |
|---|---|
DiagnosticsResult
|
DiagnosticsResult with parsed diagnostics |
Source code in src/anyenv/lsp_servers/_runner.py
run_all
async
¶
run_all(files: list[str], *, concurrency: int = 1) -> dict[str, DiagnosticsResult]
Run all applicable servers on the given files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[str]
|
File paths to check |
required |
concurrency
|
int
|
How many servers may run at once. The default runs them one after another (safe for remote executors and slow machines). |
1
|
Returns:
| Type | Description |
|---|---|
dict[str, DiagnosticsResult]
|
Dict mapping server ID to DiagnosticsResult, in registration order |
Source code in src/anyenv/lsp_servers/_runner.py
run_for_file
async
¶
run_for_file(path: str) -> list[Diagnostic]
Run all applicable servers on a single file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path to check |
required |
Returns:
| Type | Description |
|---|---|
list[Diagnostic]
|
Combined list of diagnostics from all applicable servers |
Source code in src/anyenv/lsp_servers/_runner.py
DiagnosticsResult
dataclass
¶
DotnetInstall
dataclass
¶
GemInstall
dataclass
¶
GitHubRelease
dataclass
¶
Download binary from GitHub releases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
str
|
Repository in "owner/repo" format |
required |
asset_pattern
|
str
|
Pattern with placeholders: {version}, {arch}, {platform}, {ext} |
required |
binary_name
|
str
|
Name of the binary after extraction |
required |
extract_subdir
|
str | None
|
Subdirectory within archive containing the binary |
None
|
Source code in src/anyenv/lsp_servers/_base.py
GoInstall
dataclass
¶
GoplsServer
dataclass
¶
Bases: LSPServerInfo
Go language server with go.work priority.
Source code in src/anyenv/lsp_servers/_servers/go_lsps.py
resolve_root
async
¶
Prefer go.work over go.mod for workspace support.
Source code in src/anyenv/lsp_servers/_servers/go_lsps.py
LSPServerInfo
dataclass
¶
Static configuration for an LSP server.
Subclass and override resolve_root and/or resolve_initialization for
servers that need custom behavior beyond the declarative configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Unique identifier for this server |
required |
extensions
|
list[str]
|
File extensions this server handles (e.g., [".py", ".pyi"]) |
required |
root_detection
|
RootDetection
|
Configuration for finding project root |
required |
command
|
str
|
Primary command to run the server |
required |
args
|
list[str]
|
Additional command-line arguments |
list()
|
npm_install
|
NpmInstall | None
|
npm installation config |
None
|
go_install
|
GoInstall | None
|
Go installation config |
None
|
cargo_install
|
CargoInstall | None
|
Cargo installation config |
None
|
dotnet_install
|
DotnetInstall | None
|
.NET tool installation config |
None
|
gem_install
|
GemInstall | None
|
Ruby gem installation config |
None
|
github_release
|
GitHubRelease | None
|
GitHub release download config |
None
|
initialization
|
dict[str, Any]
|
LSP initialization options sent to server |
dict()
|
env
|
dict[str, str]
|
Environment variables for the server process |
dict()
|
global_server
|
bool
|
If True, use single global instance instead of per-project |
False
|
cli_diagnostics
|
CLIDiagnosticConfig | None
|
CLI fallback for diagnostics |
None
|
Source code in src/anyenv/lsp_servers/_base.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
has_cli_diagnostics
property
¶
Check if this server supports CLI diagnostics.
build_diagnostic_command
¶
Build the CLI command for running diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[str]
|
List of file paths to check |
required |
Returns:
| Type | Description |
|---|---|
str
|
The command string to execute |
Source code in src/anyenv/lsp_servers/_base.py
can_handle
¶
Check if this server handles the given file extension.
get_env
¶
Get environment variables, merged with optional base environment.
Source code in src/anyenv/lsp_servers/_base.py
get_full_command
¶
parse_diagnostics
¶
parse_diagnostics(stdout: str, stderr: str) -> list[Diagnostic]
Parse CLI output into diagnostics.
Override for custom output formats. Default handles common JSON formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stdout
|
str
|
Standard output from the command |
required |
stderr
|
str
|
Standard error from the command |
required |
Source code in src/anyenv/lsp_servers/_base.py
resolve_env
async
¶
Resolve environment variables for the server process.
Default implementation returns the static env dict.
Override for dynamic behavior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
The resolved LSP root directory |
required |
fs
|
AsyncFileSystem
|
Filesystem to use for file operations |
required |
Source code in src/anyenv/lsp_servers/_base.py
resolve_initialization
async
¶
Resolve dynamic LSP initialization options.
Default implementation returns the static initialization dict.
Override for dynamic behavior (e.g., detecting virtualenv, tsdk path).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
The resolved LSP root directory |
required |
fs
|
AsyncFileSystem
|
Filesystem to use for file operations |
required |
Source code in src/anyenv/lsp_servers/_base.py
resolve_root
async
¶
Resolve the LSP root directory for a given file.
Default implementation searches upward from file_path for include_patterns, respecting exclude_patterns. Override for custom behavior (e.g., workspace detection).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
The file being edited |
required |
project_root
|
str
|
The overall project/workspace root (stop boundary) |
required |
fs
|
AsyncFileSystem
|
Filesystem to use for file operations |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The resolved root directory, or None if this LSP shouldn't be used |
Source code in src/anyenv/lsp_servers/_base.py
LSPServerRegistry
¶
Registry for managing LSP server configurations.
Source code in src/anyenv/lsp_servers/_registry.py
get_by_command
¶
get_by_command(command: str) -> LSPServerInfo | None
get_by_extension
¶
get_by_extension(extension: str) -> list[LSPServerInfo]
get_by_id
¶
get_by_id(server_id: str) -> LSPServerInfo | None
get_for_file
¶
get_for_file(path: Path) -> list[LSPServerInfo]
get_installable
¶
get_installable() -> list[LSPServerInfo]
get_supported_extensions
¶
register
¶
register(server: LSPServerInfo) -> None
register_defaults
¶
MypyServer
dataclass
¶
Bases: LSPServerInfo
Mypy with JSON diagnostic parsing.
Source code in src/anyenv/lsp_servers/_servers/python_lsps.py
NpmInstall
dataclass
¶
PyrightServer
dataclass
¶
Bases: LSPServerInfo
Pyright with virtualenv detection and JSON diagnostic parsing.
Source code in src/anyenv/lsp_servers/_servers/python_lsps.py
resolve_initialization
async
¶
Detect virtualenv and set pythonPath.
Source code in src/anyenv/lsp_servers/_servers/python_lsps.py
RootDetection
dataclass
¶
How to detect project root for LSP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_patterns
|
list[str]
|
File patterns that indicate project root (e.g., ["pyproject.toml"]) |
required |
exclude_patterns
|
list[str] | None
|
If these are found, skip this LSP (e.g., ["deno.json"] for typescript) |
None
|
workspace_marker
|
str | None
|
Content marker for workspace detection (e.g., "[workspace]" in Cargo.toml) |
None
|
Source code in src/anyenv/lsp_servers/_base.py
RustAnalyzerServer
dataclass
¶
Bases: LSPServerInfo
Rust analyzer with workspace detection.
Source code in src/anyenv/lsp_servers/_servers/rust_lsps.py
resolve_root
async
¶
Walk up to find workspace root containing [workspace] in Cargo.toml.
Source code in src/anyenv/lsp_servers/_servers/rust_lsps.py
SimpleCommandResult
dataclass
¶
TypeScriptServer
dataclass
¶
Bases: LSPServerInfo
TypeScript language server with tsserver path detection.
Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
resolve_initialization
async
¶
Detect tsserver.js path.