|
| 1 | +--- |
| 2 | +name: lsp-setup |
| 3 | +description: 'Install and configure LSP servers for any programming language to work with GitHub Copilot CLI. Detects the OS, installs the right LSP server, and writes the lsp-config.json configuration. Say "setup LSP" to start.' |
| 4 | +--- |
| 5 | + |
| 6 | +# LSP Setup for GitHub Copilot CLI |
| 7 | + |
| 8 | +**UTILITY SKILL** — installs and configures Language Server Protocol servers for Copilot CLI. |
| 9 | +USE FOR: "setup LSP", "install language server", "configure LSP for Java", "add TypeScript LSP", "enable code intelligence" |
| 10 | +DO NOT USE FOR: general coding tasks, IDE/editor LSP configuration, non-Copilot-CLI setups |
| 11 | + |
| 12 | +## Workflow |
| 13 | + |
| 14 | +1. **Ask the language** — use `ask_user` to ask which programming language(s) the user wants LSP support for |
| 15 | +2. **Detect the OS** — run `uname -s` (or check for Windows via `$env:OS` / `%OS%`) to determine macOS, Linux, or Windows |
| 16 | +3. **Look up the LSP server** — read `references/lsp-servers.md` for known servers, install commands, and config snippets |
| 17 | +4. **Ask scope** — use `ask_user` to ask whether the config should be user-level (`~/.copilot/lsp-config.json`) or repo-level (`.github/lsp.json`) |
| 18 | +5. **Install the server** — run the appropriate install command for the detected OS |
| 19 | +6. **Write the config** — merge the new server entry into the chosen config file (create it if missing, preserve existing entries) |
| 20 | +7. **Verify** — confirm the LSP binary is on `$PATH` and the config file is valid JSON |
| 21 | + |
| 22 | +## Configuration Format |
| 23 | + |
| 24 | +Copilot CLI reads LSP configuration from two locations (repo-level takes precedence): |
| 25 | + |
| 26 | +- **User-level**: `~/.copilot/lsp-config.json` |
| 27 | +- **Repo-level**: `.github/lsp.json` |
| 28 | + |
| 29 | +The JSON structure: |
| 30 | + |
| 31 | +```json |
| 32 | +{ |
| 33 | + "lspServers": { |
| 34 | + "<server-key>": { |
| 35 | + "command": "<binary>", |
| 36 | + "args": ["--stdio"], |
| 37 | + "fileExtensions": { |
| 38 | + ".<ext>": "<languageId>", |
| 39 | + ".<ext2>": "<languageId>" |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +### Key rules |
| 47 | + |
| 48 | +- `command` is the binary name (must be on `$PATH`) or an absolute path. |
| 49 | +- `args` almost always includes `"--stdio"` to use standard I/O transport. |
| 50 | +- `fileExtensions` maps each file extension (with leading dot) to a [Language ID](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers). |
| 51 | +- Multiple servers can coexist in `lspServers`. |
| 52 | +- When merging into an existing file, **never overwrite** other server entries — only add or update the target language key. |
| 53 | + |
| 54 | +## Behavior |
| 55 | + |
| 56 | +- Always use `ask_user` with `choices` when asking the user to pick a language or scope. |
| 57 | +- If the language is not listed in `references/lsp-servers.md`, search the web for "<language> LSP server" and guide the user through manual configuration. |
| 58 | +- If a package manager is not available (e.g. no Homebrew on macOS), suggest alternative install methods from the reference file. |
| 59 | +- After installation, run `which <binary>` (or `where.exe` on Windows) to confirm the binary is accessible. |
| 60 | +- Show the user the final config JSON before writing it. |
| 61 | +- If the config file already exists, read it first and merge — do not clobber. |
| 62 | + |
| 63 | +## Verification |
| 64 | + |
| 65 | +After setup, tell the user: |
| 66 | + |
| 67 | +1. Launch `copilot` in a project with files of the configured language |
| 68 | +2. Run `/lsp` to check the server status |
| 69 | +3. Try code intelligence features like go-to-definition or hover |
0 commit comments