Feature: LSP Integration
Relevant source files
The following files were used as context for generating this wiki page:The Language Server Protocol (LSP) integration provides Claude with real-time, IDE-like intelligence about the codebase. Instead of merely parsing code as text, this feature allows Claude to understand type information, detect errors, perform code navigation, and receive context-aware completions. This significantly enhances the quality and accuracy of code generation and modification tasks.
When Claude edits code in a file with LSP enabled, it can immediately identify if the changes introduce issues like type errors. This capability transforms Claude from a text generator into a more sophisticated coding assistant that is aware of the code's semantic structure.
Sources: README.md:300-304
Architecture
LSP integration works by connecting Claude to language-specific server plugins. These plugins analyze the code and provide structured information back to Claude, mimicking how an IDE communicates with its language support tools.
The following diagram illustrates the data flow for LSP integration.
This diagram shows Claude interacting with various LSP plugins, which in turn analyze the corresponding source files to provide real-time code intelligence.
Sources: README.md:300-304, README.md:316-322
Enabling LSP
LSP support is activated by enabling specific plugins within the .claude/settings.json configuration file. Each plugin corresponds to a particular programming language.
Sources: README.md:306-307
Configuration
To enable LSP, you add the desired plugins to the enabledPlugins object in .claude/settings.json.
{
"enabledPlugins": {
"typescript-lsp@claude-plugins-official": true,
"pyright-lsp@claude-plugins-official": true
}
}
Sources: README.md:309-315
Core Capabilities
Once enabled, LSP provides Claude with several key capabilities that mirror modern IDE functionality.
| Feature | Description |
|---|---|
| Diagnostics | Provides real-time errors and warnings after every edit. |
| Type Information | Offers hover info, function signatures, and type definitions. |
| Code Navigation | Enables "go to definition" and "find references" functionality. |
| Completions | Suggests context-aware symbols and code snippets. |
Sources: README.md:324-331
Available LSP Plugins
The repository documentation lists several official LSP plugins. Note that these plugins require the corresponding language server binary to be installed on the system first.
| Plugin | Language | Prerequisite Command |
|---|---|---|
typescript-lsp | TypeScript/JavaScript | npm install -g typescript-language-server typescript |
pyright-lsp | Python | pip install pyright |
rust-lsp | Rust | rustup component add rust-analyzer |
Sources: README.md:333-339
Custom LSP Configuration
For more advanced control over a language server's behavior, a .lsp.json file can be created in the project root. This file allows for specifying custom commands, arguments, and initialization options for each language server.
Sources: README.md:341-342
Example .lsp.json
The following is an example configuration for the TypeScript language server, setting a preference for single quotes.
{
"typescript": {
"command": "typescript-language-server",
"args": ["--stdio"],
"extensionToLanguage": {
".ts": "typescript",
".tsx": "typescriptreact"
},
"initializationOptions": {
"preferences": {
"quotePreference": "single"
}
}
}
}
Sources: README.md:344-361
Troubleshooting
If LSP features are not working as expected, the following steps can be taken to diagnose the issue:
- Verify Binary Installation: Ensure the language server executable is installed and available in the system's
PATH.which typescript-language-server - Enable Debug Logging: Run Claude with a special flag to see detailed LSP communication logs.
claude --enable-lsp-logging - Check Plugin Status: Use the built-in
/plugincommand within Claude to view the status and any potential errors for loaded plugins.
Sources: README.md:363-376