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 LSP tool 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 LSP tool

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

Bash
npm install -g typescript-language-server typescript

Python

Bash
npm install -g pyright
# or
pip install pyright

You need the pyright-langserver command.

Go

Bash
go install golang.org/x/tools/gopls@latest

Make sure $GOPATH/bin is in your $PATH.

Rust

Bash
rustup component add rust-analyzer

Languages with an official plugin

LanguagePluginBinary
C/C++clangd-lspclangd
C#csharp-lspcsharp-ls
Gogopls-lspgopls
Javajdtls-lspjdtls
Kotlinkotlin-lspkotlin-lsp
Lualua-lsplua-language-server
PHPphp-lspintelephense
Pythonpyright-lsppyright-langserver
Rubyruby-lspruby-lsp
Rustrust-analyzer-lsprust-analyzer
Swiftswift-lspsourcekit-lsp
TypeScript / JavaScripttypescript-lsptypescript-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

TEXT
/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

Bash
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:

Bash
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

Bash
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:

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. Press Ctrl+O to read the issues.
  • If it doesn't appear, open the Errors tab in /plugin. A row reading Executable not found in $PATH: "<binary>" names the binary to install.

For navigation, ask something like:

TEXT
> Where is the ConfigManager class defined in this project?

Troubleshooting

SymptomSolution
No diagnostics lineCheck that the binary is in $PATH and the plugin is enabled
Plugin installed but not workingRun /reload-plugins or restart Claude Code
"Executable not found" in the /plugin Errors tabInstall the language server binary, check PATH, then start a new session from a shell with the right PATH
LSP only used occasionallyAdd "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:

Markdown
## 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.