lsp.mdx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ---
  2. title: "LSP"
  3. description: ""
  4. ---
  5. Language Server Protocol (LSP) integrations can provide code diagnostics,
  6. symbols, definitions, references, and other language-aware context.
  7. <Warning>
  8. OpenCode V2 does not yet have an LSP runtime or built-in language servers.
  9. The `lsp` configuration is accepted and preserved, but it does not currently
  10. start or download servers, expose an LSP tool, or add diagnostics to file tool
  11. results.
  12. </Warning>
  13. ## Built-in servers
  14. There are no built-in LSP servers in the current V2 implementation. Setting
  15. `lsp` to `true` declares that built-ins should be enabled, but has no runtime
  16. effect until V2 provides a server registry and LSP runtime.
  17. ```jsonc title="opencode.jsonc"
  18. {
  19. "$schema": "https://opencode.ai/config.json",
  20. "lsp": true
  21. }
  22. ```
  23. ## Configuration
  24. The `lsp` field accepts a boolean or an object keyed by server name:
  25. ```jsonc title="opencode.jsonc"
  26. {
  27. "$schema": "https://opencode.ai/config.json",
  28. "lsp": {
  29. "custom-typescript": {
  30. "command": ["typescript-language-server", "--stdio"],
  31. "extensions": [".ts", ".tsx"],
  32. "env": {
  33. "TSS_LOG": "-level verbose"
  34. },
  35. "initialization": {
  36. "preferences": {
  37. "importModuleSpecifierPreference": "relative"
  38. }
  39. }
  40. }
  41. }
  42. }
  43. ```
  44. Each enabled server entry has this shape:
  45. | Property | Type | Required | Description |
  46. | --- | --- | --- | --- |
  47. | `command` | `string[]` | Yes | Executable followed by any arguments. |
  48. | `extensions` | `string[]` | No | File extensions associated with the server, including the leading dot. |
  49. | `disabled` | `boolean` | No | Disables the entry when `true`. |
  50. | `env` | `Record<string, string>` | No | Environment variables for the server process. The property is named `env`, not `environment`. |
  51. | `initialization` | `Record<string, unknown>` | No | Server-specific options for the LSP `initialize` request. |
  52. The only entry that may omit `command` is the disable-only form:
  53. ```jsonc
  54. {
  55. "lsp": {
  56. "typescript": {
  57. "disabled": true
  58. }
  59. }
  60. }
  61. ```
  62. Server names are arbitrary. The V2 schema permits `extensions` to be omitted,
  63. including for a custom server, although a future runtime will need a way to
  64. associate that server with files.
  65. ## Disable LSP
  66. Omit `lsp` when no configuration is needed. Set it to `false` to explicitly
  67. disable the whole integration, including when a lower-priority configuration
  68. set it to `true` or supplied an object:
  69. ```jsonc title="opencode.jsonc"
  70. {
  71. "$schema": "https://opencode.ai/config.json",
  72. "lsp": false
  73. }
  74. ```
  75. Use `{ "disabled": true }` under a server name to disable one server while
  76. retaining the object form. `OPENCODE_DISABLE_LSP_DOWNLOAD` is not used by V2;
  77. V2 currently performs no automatic LSP downloads.
  78. ## Current usage
  79. V2 loads and validates the configuration shape for compatibility and future
  80. integration. It does not currently use LSP when reading, writing, editing, or
  81. patching files, and those tools do not notify a language server or return LSP
  82. diagnostics.
  83. For reliable feedback today, have the agent run the project's lint, typecheck,
  84. test, or compiler commands. Record those commands in an `AGENTS.md` file or a
  85. skill so the agent knows when and where to run them.