# Claude Code 开启 LSP


本文是工具篇，主要介绍 Claude code 如何开启 LSP

<!--more-->

## 前提条件

1. Claude Code 版本 2.0.74 或 更高版本（运行`claude -version`检查）
2. 已安装语言服务器

## 开启 LSP

将此添加到`~/.claude/settings.json`

```json
{
"env": {
"ENABLE_LSP_TOOL": "1"
}
}
```

## 安装 marketplace

首先，更新`marketplace`

`claude plugin marketplace update claude-plugins-official`

## 安装语言服务器

| Language | Plugin | Install Command |
| --- | --- | --- |
| Python | `pyright-lsp` | `npm i -g pyright` |
| TypeScript/JS | `typescript-lsp` | `npm i -g typescript-language-server typescript` |
| Go | `gopls-lsp` | `go install golang.org/x/tools/gopls@latest` |
| Rust | `rust-analyzer-lsp` | `rustup component add rust-analyzer` |
| Java | `jdtls-lsp` | `brew install jdtls` |
| C/C++ | `clangd-lsp` | `brew install llvm` |
| C# | `csharp-lsp` | `dotnet tool install -g csharp-ls` |
| PHP | `php-lsp` | `npm i -g intelephense` |
| Kotlin | `kotlin-lsp` | GitHub releases |
| Swift | `swift-lsp` | Included with Xcode |
| Lua | `lua-lsp` | GitHub releases |

## 安装插件

```bash
# Python
claude plugin install pyright-lsp
# TypeScript/JS
claude plugin install typescript-lsp
# Go
claude plugin install gopls-lsp
# Rust
claude plugin install rust-analyzer-lsp
# Java
claude plugin install jdtls-lsp
# C/C++
claude plugin install clangd-lsp
# C#
claude plugin install csharp-lsp
# PHP
claude plugin install php-lsp
# Kotlin
claude plugin install kotlin-lsp
# Swift
claude plugin install swift-lsp
# Lua
claude plugin install lua-lsp
```

## 查看 Claude Code 插件

`claude plugin list`

![alt text](https://cdn.assets.inkyflow.com/content/posts/learning/ClaudeCode/b5226dbd_image.jpg)

---

> 作者: [人生一点墨](https://inkyflow.com)  
> URL: https://inkyflow.com/posts/learning/claudecode/enable-claude-code-lsp/  

