Give GitHub Copilot CLI real code intelligence with language servers (opens in new tab)
GitHub Copilot CLI can understand code far more accurately when connected to a Language Server Protocol (LSP) server. Without LSP, it relies on grep, package-directory browsing, and bytecode extraction, which can miss types, overloads, and dependencies. The LSP Setup skill automates server installation and configuration for 14 languages, giving the CLI capabilities such as type resolution, go-to-definition, and reference search. ## The Problem with Heuristic Code Understanding - Without an LSP server, Copilot CLI may: - Extract Java JAR files and grep through `.class` files. - Read installed Python packages directly. - Search through TypeScript’s `node_modules`. - These approaches use text and pattern matching rather than semantic analysis. - They often fail to correctly understand: - Generics and overloads. - Transitive types. - Compiled dependencies. - Exact method signatures and symbol relationships. - LSP requests such as `textDocument/definition` return precise source locations, resolved types, and signatures. ## How the LSP Setup Skill Works The skill automates a seven-step process: - **Language selection:** Uses `ask_user` to determine the required language. - **Operating system detection:** Identifies macOS, Linux, or Windows so it can choose the correct installation commands. - **Server lookup:** Reads curated data for 14 languages from `references/lsp-servers.md`. - **Configuration scope:** Supports: - User-wide configuration at `~/.copilot/lsp-config.json`. - Repository-specific configuration at `lsp.json` or `.github/lsp.json`. - Repository configuration takes precedence. - **Installation:** Runs the appropriate package-manager or platform-specific command, such as: - `npm install -g typescript typescript-language-server` - `brew install jdtls` - `rustup component add rust-analyzer` - **Configuration:** Adds a server under the `lspServers` object, mapping commands and file extensions to language identifiers. - **Verification:** Confirms the executable is on `PATH` and checks that the configuration is valid JSON. The skill merges new settings with existing configuration instead of overwriting other servers. It also accounts for transport differences, such as servers requiring `--stdio`. ## Supported Languages and Custom Setup - The skill provides predefined installation and configuration details for 14 languages. - If a language is not included, Copilot CLI can search for a suitable server and guide the user through manual configuration. - Each server configuration specifies: - The executable command. - Optional arguments. - File-extension mappings such as `.java` to `java`. ## Benefits After Configuration With LSP enabled, Copilot CLI can: - Resolve types across external dependencies. - Jump to definitions in third-party libraries. - Find every reference to a symbol. - Display hover documentation for functions, classes, and types. - Reduce unnecessary tool calls and avoid incorrect assumptions about APIs. - Handle larger and more complex coding tasks with IDE-like semantic understanding. ## Getting Started - Download the LSP Setup skill from the Awesome Copilot project. - Extract it into `~/.copilot/skills/`. - Restart Copilot CLI. - Ask the agent to set up LSP for a language, such as Java or Python. - Restart the CLI again, run `/lsp`, and test navigation on a dependency symbol. The practical recommendation is to configure an LSP server for each language used in a project. The setup gives Copilot CLI structured code intelligence instead of forcing it to reconstruct APIs through text searches and binary inspection.