Practical SkillsLanguage ServerLSP Overview

Language Server Protocol (LSP)

The Language Server Protocol (LSP) is an open, JSON-RPC-based protocol for communication between code editors and language servers. Originally developed by Microsoft for VS Code, it has since become an industry standard.

Claude Code natively supports LSP, giving Claude the same intelligent code capabilities as a professional IDE while processing your code.

What Does LSP Bring to Claude Code?

Through LSP integration, Claude gains the following capabilities:

FeatureDescription
Real-time diagnosticsClaude sees errors and warnings immediately after every edit
Go to definitionQuickly locate where a function, variable, or class is defined
Find referencesFind all usages of a code symbol across the project
Hover informationGet type information and documentation comments
Language awarenessUnderstand the type and context of code symbols

LSP is a native plugin feature of Claude Code — it does not depend on VS Code or any other IDE. You can use Claude Code independently in a terminal and enjoy full code intelligence support.

How It Works

┌─────────────────┐     LSP Protocol      ┌──────────────────────┐
│   Claude Code   │ ◄──────────────────► │  Language Server     │
│   (client)      │    JSON-RPC           │  (e.g. typescript-   │
│                 │                       │   language-server)   │
└─────────────────┘                       └──────────────────────┘
         │                                          │
         │                                          │
         ▼                                          ▼
  Sends code action requests               Analyzes code and returns results
  (go to definition, find references…)    (locations, types, errors…)

Once you install and enable an LSP plugin:

  1. On startup: Claude Code automatically starts the language servers configured in installed plugins
  2. On edit: The language server analyzes your code in real time after every file change
  3. Diagnostics: Errors and warnings are automatically fed back to Claude
  4. Navigation: Claude can use go-to-definition, find-references, and other operations

Installing LSP Plugins

The easiest approach is to install from the official plugin marketplace:

# Run inside Claude Code
/plugin
# Then select the Discover tab and search for "lsp"

Officially Supported LSP Plugins

PluginLanguage ServerInstallation
pyright-lspPyright (Python)pip install pyright or npm install -g pyright
typescript-lspTypeScript Language Servernpm install -g typescript-language-server typescript
rust-lsprust-analyzerSee installation guide
⚠️

LSP plugins are configuration files only — they do not include the language server binary itself. You must install the corresponding language server first, then install the plugin.

LSP Plugin Configuration Format

If the official marketplace doesn’t have the language you need, you can create your own LSP plugin.

Configuration File Location

  • Standalone file: .lsp.json in the plugin root directory
  • Inline configuration: in the lspServers field of plugin.json

Configuration Example

{
  "typescript": {
    "command": "typescript-language-server",
    "args": ["--stdio"],
    "extensionToLanguage": {
      ".ts": "typescript",
      ".tsx": "typescriptreact",
      ".js": "javascript",
      ".jsx": "javascriptreact"
    }
  }
}

Required Fields

FieldDescription
commandLSP binary name (must be on your PATH)
extensionToLanguageMapping of file extensions to language identifiers

Optional Fields

FieldDescription
argsCommand-line arguments for starting the language server
transportCommunication mode: stdio (default) or socket
envEnvironment variables to set when starting the server
initializationOptionsOptions passed to the server during initialization
settingsSettings sent via workspace/didChangeConfiguration
workspaceFolderWorkspace folder path
startupTimeoutMaximum time to wait for server startup (milliseconds)
shutdownTimeoutMaximum time to wait for graceful shutdown (milliseconds)
restartOnCrashWhether to automatically restart the server on crash
maxRestartsMaximum restart attempts before giving up
loggingConfigDebug logging configuration

Debugging LSP Issues

If you encounter LSP-related problems, enable verbose logging:

claude --enable-lsp-logging

Log files are located in the ~/.claude/debug/ directory.

Common Issues

“Executable not found in $PATH”

The language server is not installed or is not on your system PATH. Install the corresponding language server first.

“No LSP server available for file type”

No LSP plugin is configured for that file type. Check that the plugin is correctly installed and that extensionToLanguage includes the extension in question.

Available LSP Plugins

Reference Resources


MIT 2026 © Nextra.
加入社群CC Club返回官网