Setting Up LSP in Claude Code — 50x Faster Code Navigation
By default, Claude Code uses grep and glob to navigate codebases. Since it's purely text-based search, answering "where is this function defined?" means reading through dozens of matches one by one — a process that can take 30–60 seconds. With LSP enabled, the same operation takes around 50ms. It's the same principle behind "Go to Definition" in your IDE.
This guide covers how to configure LSP in Claude Code and install language servers for the languages you use.
What Is LSP?
Language Server Protocol is a standard protocol created by Microsoft in 2016. It defines how editors communicate with language servers — it's what powers type hints when you hover over a function in VS Code, "Go to Definition" jumps, and red underlines for errors.
Connecting LSP to Claude Code gives the AI access to the same capabilities:
- goToDefinition — jump to the exact location where a symbol is defined
- findReferences — find everywhere a function or variable is used
- hover — inspect type information
- diagnostics — detect errors in real time after editing a file
Prerequisites
- Claude Code v2.0.74 or later (check with
claude --version) - The Language Server binary for your language must be available on
$PATH
Step 1: Enable the LSP Tool
Add the ENABLE_LSP_TOOL environment variable to ~/.claude/settings.json:
{
"env": {
"ENABLE_LSP_TOOL": "1"
}
}
As a fallback, it's also a good idea to add it to your shell profile (.zshrc, .bashrc):
export ENABLE_LSP_TOOL=1
Note:
ENABLE_LSP_TOOLappeared in the official changelog for v2.0.74. Prior to that, it was a flag discovered by the community via GitHub Issue #15619. It may change or become unnecessary in future versions.
Step 2: Install Language Server Binaries
Install the Language Server for your language. Claude Code uses the same servers as VS Code and other IDEs.
TypeScript / JavaScript
npm install -g @vtsls/language-server typescript
Python
pip install pyright
# or
npm install -g pyright
Go
go install golang.org/x/tools/gopls@latest
Make sure $GOPATH/bin is included in your $PATH.
Rust
rustup component add rust-analyzer
Dart
# Included with the Flutter SDK
# Make sure the `dart language-server` path is on $PATH
Other Languages
Java (jdtls), C/C++ (clangd), C# (roslyn), PHP (intelephense), Kotlin (kotlin-lsp), Ruby (solargraph), and more are also supported. Install the respective language server and register it on $PATH.
Step 3: Install LSP Plugins
Claude Code manages LSP servers through a plugin marketplace system. The official Anthropic marketplace (claude-plugins-official) is available automatically.
Install from the Official Marketplace
Run the /plugin command inside a Claude Code session and select the plugin for your language:
/plugin
In the Browse tab, select plugins with the spacebar and install them.
Install via CLI
claude plugin install pyright-lsp@claude-plugins-official
claude plugin install typescript-lsp@claude-plugins-official
claude plugin install gopls-lsp@claude-plugins-official
Third-Party Marketplaces (Optional)
Community marketplaces with broader language support are also available:
claude plugin marketplace add boostvolt/claude-code-lsps
claude plugin marketplace add Piebald-AI/claude-code-lsps
These marketplaces add support for Dart, Vue, OCaml, Ada, and more.
Verify Plugin Is Enabled
After installation, plugins may be in a disabled state — this is the most common gotcha:
claude plugin list
# If any plugins show Status: disabled:
claude plugin enable <plugin-name>
You can also explicitly enable plugins in settings.json to be safe:
{
"env": {
"ENABLE_LSP_TOOL": "1"
},
"enabledPlugins": {
"pyright-lsp@claude-plugins-official": true,
"typescript-lsp@claude-plugins-official": true
}
}
Step 4: Verify and Restart
Once setup is complete, restart Claude Code. You can check the debug log to confirm LSP servers are loading:
~/.claude/debug/latest
Search the log for Total LSP servers loaded: N. If N > 0, you're good.
Test it in practice:
> Where is the ConfigManager class defined in this project?
With LSP active, you should see a log entry like ● LSP(operation: "goToDefinition", ...) and get back the exact file and line number immediately.
Troubleshooting
| Symptom | Fix |
|---|---|
| "No LSP server available for file type" | Check that the language binary is on $PATH; confirm the plugin is enabled |
| Plugin installed but not working | Restart Claude Code |
"Executable not found" in /plugin Errors tab | Reinstall the Language Server binary and verify PATH |
| LSP is only used sometimes | Add an explicit instruction in CLAUDE.md (see below) |
Add an LSP-First Instruction to CLAUDE.md
Claude Code's default system prompt favors grep/glob for code navigation. To increase how often it reaches for LSP, add the following to your project's CLAUDE.md:
## Code Navigation
- Prefer LSP tools when looking up function definitions, finding references, or checking types.
- Use grep/glob only for plain text search or file discovery.
Keep in mind that this competes with the system prompt, so LSP won't always win. It's better to think of LSP and grep as complementary rather than alternatives.
Wrap-Up
Setup takes about two minutes. With LSP enabled, Claude Code understands your codebase semantically rather than as raw text — making definition lookups and refactoring significantly more accurate and faster in large codebases. It's still somewhat experimental, but once it's configured, the difference is immediately noticeable.