lsp-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLSP Setup for GitHub Copilot CLI
适用于GitHub Copilot CLI的LSP设置
UTILITY SKILL — installs and configures Language Server Protocol servers for Copilot CLI.
USE FOR: "setup LSP", "install language server", "configure LSP for Java", "add TypeScript LSP", "enable code intelligence", "I need go-to-definition", "find references not working", "need better code understanding"
DO NOT USE FOR: general coding tasks, IDE/editor LSP configuration, non-Copilot-CLI setups
实用技能 — 为Copilot CLI安装并配置Language Server Protocol服务端。
适用场景:"setup LSP"、"install language server"、"configure LSP for Java"、"add TypeScript LSP"、"enable code intelligence"、"I need go-to-definition"、"find references not working"、"need better code understanding"
不适用场景:通用编码任务、IDE/编辑器的LSP配置、非Copilot CLI相关的设置
Workflow
工作流程
- Ask the language — use to ask which programming language(s) the user wants LSP support for
ask_user - Detect the OS — run (or check for Windows via
uname -s/$env:OS) to determine macOS, Linux, or Windows%OS% - Look up the LSP server — read for known servers, install commands, and config snippets
references/lsp-servers.md - Ask scope — use to ask whether the config should be user-level (
ask_user) or repo-level (~/.copilot/lsp-config.jsonat the repo root orlsp.json).github/lsp.json - Install the server — run the appropriate install command for the detected OS
- Write the config — merge the new server entry into the chosen config file (for user-level;
~/.copilot/lsp-config.jsonorlsp.jsonfor repo-level). If a repo-level config already exists, keep using that location; otherwise ask the user which repo-level location they prefer. Create the file if missing and preserve existing entries..github/lsp.json - Verify — confirm the LSP binary is on and the config file is valid JSON
$PATH
- 询问编程语言 — 使用询问用户需要为哪些编程语言提供LSP支持
ask_user - 检测操作系统 — 运行(Windows环境下可通过
uname -s/$env:OS检查)判断是macOS、Linux还是Windows%OS% - 查找对应LSP服务端 — 读取获取已知服务端、安装命令和配置片段
references/lsp-servers.md - 询问配置作用范围 — 使用询问配置应该为用户级(
ask_user)还是仓库级(仓库根目录的~/.copilot/lsp-config.json或lsp.json).github/lsp.json - 安装服务端 — 运行适配检测到的操作系统的对应安装命令
- 写入配置 — 将新的服务端条目合并到选定的配置文件中(用户级对应;仓库级对应
~/.copilot/lsp-config.json或lsp.json)。如果已有仓库级配置,继续使用原有位置;否则询问用户偏好的仓库级存储位置。文件不存在则创建,同时保留所有已有条目。.github/lsp.json - 验证配置 — 确认LSP二进制文件在中,且配置文件为合法JSON格式
$PATH
Configuration Format
配置格式
Copilot CLI reads LSP configuration from user-level or repo-level locations, and repo-level config takes precedence over user-level config:
- User-level:
~/.copilot/lsp-config.json - Repo-level: (repo root) or
lsp.json.github/lsp.json
The JSON structure:
json
{
"lspServers": {
"<server-key>": {
"command": "<binary>",
"args": ["--stdio"],
"fileExtensions": {
".<ext>": "<languageId>",
".<ext2>": "<languageId>"
}
}
}
}Copilot CLI会从用户级或仓库级位置读取LSP配置,仓库级配置优先级高于用户级配置:
- 用户级:
~/.copilot/lsp-config.json - 仓库级:(仓库根目录)或
lsp.json.github/lsp.json
JSON结构如下:
json
{
"lspServers": {
"<server-key>": {
"command": "<binary>",
"args": ["--stdio"],
"fileExtensions": {
".<ext>": "<languageId>",
".<ext2>": "<languageId>"
}
}
}
}Key rules
关键规则
- is the binary name (must be on
command) or an absolute path.$PATH - almost always includes
argsto use standard I/O transport."--stdio" - maps each file extension (with leading dot) to a Language ID.
fileExtensions - Multiple servers can coexist in .
lspServers - When merging into an existing file, never overwrite other server entries — only add or update the target language key.
- 是二进制文件名称(必须在
command中)或绝对路径。$PATH - 几乎总是包含
args,用于使用标准I/O传输。"--stdio" - 将每个文件扩展名(带开头的点)映射到语言ID。
fileExtensions - 中可同时存在多个服务端配置。
lspServers - 合并到已有文件时,绝对不要覆盖其他服务端条目——仅添加或更新目标语言对应的键。
Behavior
行为规范
- Always use with
ask_userwhen asking the user to pick a language or scope.choices - If the language is not listed in , search the web for "<language> LSP server" and guide the user through manual configuration.
references/lsp-servers.md - If a package manager is not available (e.g. no Homebrew on macOS), suggest alternative install methods from the reference file.
- After installation, run (or
which <binary>on Windows) to confirm the binary is accessible.where.exe - Show the user the final config JSON before writing it.
- If the config file already exists, read it first and merge — do not clobber.
- 要求用户选择语言或作用范围时,始终使用带参数的
choices。ask_user - 如果语言未在中列出,搜索网络查找"<language> LSP server",引导用户完成手动配置。
references/lsp-servers.md - 如果缺少对应的包管理器(例如macOS上没有Homebrew),从参考文件中推荐其他安装方式。
- 安装完成后,运行(Windows下为
which <binary>)确认二进制文件可访问。where.exe - 写入配置前向用户展示最终的配置JSON。
- 如果配置文件已存在,先读取内容再合并——不要直接覆盖原有内容。
Verification
验证步骤
After setup, tell the user:
- Type to quit Copilot CLI — this is required so the new LSP configuration is loaded on next launch
/exit - Re-launch in a project with files of the configured language
copilot - Run to check the server status
/lsp - Try code intelligence features like go-to-definition or hover
设置完成后,告知用户以下操作:
- 输入退出Copilot CLI——这一步是必须的,这样下次启动时才会加载新的LSP配置
/exit - 在包含对应配置语言文件的项目中重新启动
copilot - 运行检查服务端状态
/lsp - 测试代码智能功能,例如跳转到定义、悬停提示等