Setting Up LSP in Claude Code
By default, Claude Code uses grep and glob to navigate codebases. Because it's text search, answering "where is this function defined?" means reading through matches one by one. Connecting LSP lets Claude look up symbols directly, the same way "Go to Definition" works in your IDE.
This guide covers how to connect LSP to Claude Code: installing a language server and installing a plugin.
What Is LSP?
The Language Server Protocol is a protocol Microsoft announced in 2016. It defines how editors talk to language servers. In VS Code, the type info that pops up on hover, "Go to Definition," and red error squiggles all work through LSP.
Once LSP is connected to Claude Code, Claude gets the same capabilities:
- Diagnostics after edits — each time Claude edits a file, it gets the type errors, missing imports, and other problems the language server reports
- Code navigation — the
LSPtool jumps to definitions, finds references, gets type info, lists symbols in a file, searches workspace symbols, finds implementations, and traces call hierarchies. The tool is read-only
Prerequisites
- The LSP tool was added in Claude Code v2.0.74 (check with
claude --version) - A terminal session. In cloud sessions (such as claude.ai/code), plugin language servers don't start
- No environment variable is needed. Per the official docs, installing the language server binary and the plugin turns on the
LSPtool
Step 1: Install the Language Server Binary
A plugin only tells Claude Code which command starts the language server; it doesn't include the server itself. Install the binary first.
TypeScript / JavaScript
npm install -g typescript-language-server typescript
Python
npm install -g pyright
# or
pip install pyright
You need the pyright-langserver command.
Go
go install golang.org/x/tools/gopls@latest
Make sure $GOPATH/bin is in your $PATH.
Rust
rustup component add rust-analyzer
Languages with an official plugin
| Language | Plugin | Binary |
|---|---|---|
| C/C++ | clangd-lsp | clangd |
| C# | csharp-lsp | csharp-ls |
| Go | gopls-lsp | gopls |
| Java | jdtls-lsp | jdtls |
| Kotlin | kotlin-lsp | kotlin-lsp |
| Lua | lua-lsp | lua-language-server |
| PHP | php-lsp | intelephense |
| Python | pyright-lsp | pyright-langserver |
| Ruby | ruby-lsp | ruby-lsp |
| Rust | rust-analyzer-lsp | rust-analyzer |
| Swift | swift-lsp | sourcekit-lsp |
| TypeScript / JavaScript | typescript-lsp | typescript-language-server |
After installing, confirm the binary is on the PATH of the shell you start claude from (e.g., which typescript-language-server).
Step 2: Install the LSP Plugin
LSP plugins live in Anthropic's official marketplace (claude-plugins-official), which is registered automatically the first time you start a terminal session.
Install inside a session
/plugin install typescript-lsp@claude-plugins-official
You can also run /plugin alone and search the Discover tab. When installing, you choose a scope (user / project / local).
Install from the 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
Plugins installed from the shell load the next time you start Claude Code, or when you run /reload-plugins in an open session.
Third-Party Marketplaces (Optional)
For languages without an official plugin, such as Dart, there are community marketplaces:
claude plugin marketplace add boostvolt/claude-code-lsps
claude plugin marketplace add Piebald-AI/claude-code-lsps
Anthropic doesn't review third-party marketplaces, so check what's in them before adding one. You can also write your own plugin with an .lsp.json file.
Verify the Plugin Is Enabled
claude plugin list
# If any plugin shows Status: disabled:
claude plugin enable <plugin-name>
A user-scope install is recorded under enabledPlugins in ~/.claude/settings.json:
{
"enabledPlugins": {
"pyright-lsp@claude-plugins-official": true,
"typescript-lsp@claude-plugins-official": true
}
}
Step 3: Confirm It Works
The language server starts the first time Claude edits a file with one of the plugin's extensions. To check, ask Claude to introduce a type error in a file of that language and then fix it.
- If
Found N new diagnostic issues in M files (ctrl+o to expand)appears under the edit, the server started. PressCtrl+Oto read the issues. - If it doesn't appear, open the Errors tab in
/plugin. A row readingExecutable not found in $PATH: "<binary>"names the binary to install.
For navigation, ask something like:
> Where is the ConfigManager class defined in this project?
Troubleshooting
| Symptom | Solution |
|---|---|
| No diagnostics line | Check that the binary is in $PATH and the plugin is enabled |
| Plugin installed but not working | Run /reload-plugins or restart Claude Code |
"Executable not found" in the /plugin Errors tab | Install the language server binary, check PATH, then start a new session from a shell with the right PATH |
| LSP only used occasionally | Add "Prefer LSP for code navigation" to your CLAUDE.md |
Adding LSP Priority Instructions to CLAUDE.md
Claude sometimes reaches for grep even when looking up a definition. To get it to use LSP more often, add this to CLAUDE.md at your project root:
## Code Navigation
- Use LSP tools first for finding definitions, exploring references, and checking types.
- Use grep/glob only for text search or file exploration.
Even so, Claude won't always use LSP. grep is still used where text search is what's needed.
Wrap-Up
Install the language server binary and the matching LSP plugin from the official marketplace, and Claude gets diagnostics right after its edits and can find code by symbol.