What?

LSP (Language Server Protocol) integration gives Claude Code access to real-time diagnostics, type information, and code intelligence from language servers - the same ones that power your IDE.

Why?

Without LSPs, Claude Code relies on static analysis (grep, reading files). With LSPs, it gets compiler-level understanding: type errors, unused imports, missing implementations, and more — before you even run the code. This means fewer broken edits and better code suggestions.

How?

1. Install the Language Server Binary

The LSP binary must be available on your PATH.

# Rust
rustup component add rust-analyzer
 
# Java
brew install jdtls
 
# Python
pip install pyright
 
# Swift (included with Xcode)
xcrun --find sourcekit-lsp
 
# TypeScript/JavaScript
npm install -g typescript-language-server typescript

2. Enable LSP in Settings

Add to your ~/.claude/settings.json:

{
  "env": {
    "ENABLE_LSP_TOOL": "1"
  }
}

3. Configure Language Servers

Create a .lsp.json file in your project root (or in a Claude Code plugin):

Rust

{
  "rust": {
    "command": "rust-analyzer",
    "args": ["serve"],
    "extensionToLanguage": {
      ".rs": "rust"
    }
  }
}

Java

{
  "java": {
    "command": "jdtls",
    "args": [],
    "extensionToLanguage": {
      ".java": "java"
    },
    "initializationOptions": {
      "codeGeneration": {
        "toString": {
          "template": "${object.className}{${member.name()}=${member.value}}"
        }
      }
    }
  }
}

Python

{
  "python": {
    "command": "pyright",
    "args": ["--server", "--outputjson"],
    "extensionToLanguage": {
      ".py": "python"
    }
  }
}

Swift

{
  "swift": {
    "command": "sourcekit-lsp",
    "args": [],
    "extensionToLanguage": {
      ".swift": "swift"
    }
  }
}

TypeScript / JavaScript

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

All-in-One .lsp.json

Combine them into a single file:

{
  "rust": {
    "command": "rust-analyzer",
    "args": ["serve"],
    "extensionToLanguage": { ".rs": "rust" }
  },
  "java": {
    "command": "jdtls",
    "args": [],
    "extensionToLanguage": { ".java": "java" }
  },
  "python": {
    "command": "pyright",
    "args": ["--server", "--outputjson"],
    "extensionToLanguage": { ".py": "python" }
  },
  "swift": {
    "command": "sourcekit-lsp",
    "args": [],
    "extensionToLanguage": { ".swift": "swift" }
  },
  "typescript": {
    "command": "typescript-language-server",
    "args": ["--stdio"],
    "extensionToLanguage": {
      ".ts": "typescript",
      ".tsx": "typescriptreact",
      ".js": "javascript",
      ".jsx": "javascriptreact"
    }
  }
}

Configuration Reference

FieldRequiredDescription
commandYesLSP binary name (must be in PATH)
argsNoCommand-line arguments
extensionToLanguageYesMaps file extensions to language IDs
transportNostdio (default) or socket
envNoEnvironment variables for the server
initializationOptionsNoOptions sent during LSP init
settingsNoWorkspace configuration settings
startupTimeoutNoMax startup wait (ms, default: 60000)
maxRestartsNoMax restart attempts (default: 3)

Official Plugins (Alternative)

Instead of manual .lsp.json config, install official plugins:

claude plugin install rust-analyzer-lsp@claude-plugins-official
claude plugin install jdtls-lsp@claude-plugins-official
claude plugin install pyright-lsp@claude-plugins-official
claude plugin install swift-lsp@claude-plugins-official
claude plugin install typescript-lsp@claude-plugins-official

Then enable in ~/.claude/settings.json:

{
  "enabledPlugins": {
    "rust-analyzer-lsp@claude-plugins-official": true,
    "jdtls-lsp@claude-plugins-official": true,
    "pyright-lsp@claude-plugins-official": true,
    "swift-lsp@claude-plugins-official": true,
    "typescript-lsp@claude-plugins-official": true
  }
}