Description
I am trying to get LSP working for my repository with opencode. I have clangd and pyright server setup as follows in my opencode.json
"lsp": {
"python": {
"command": [
"pyright-langserver",
"--stdio"
],
"extensions": [
".py"
]
},
"cpp": {
"command": [
"<custom-script-running-clangd-with-some-extra-args>",
"--background-index"
],
"extensions": [
".c",
".h",
".cpp",
".cxx",
".cc",
".hh",
".inl",
".hpp",
".hxx"
]
}
},
I am seeing a couple of issues:
- Without
OPENCODE_EXPERIMENTAL_LSP_TOOL=true explicitly set when running opencode, the agent never tries to use LSP tools and always defaults to grep
- With
OPENCODE_EXPERIMENTAL_LSP_TOOL=true, the agent tries to use LSP tools but always fails
Example prompt:
Find abc symbol, its implementation and references
Example response
⚙ lsp [operation=workspaceSymbol, filePath=<workspace-root-directory>, line=1, character=1, query=abc]
No LSP server available for this file type.
I wonder why filePath being set to workspace root directory in the LSP query and if thats causes what is causing the issue. I have similar server setup with Copilot CLI under .github/lsp.json and don't see it specifying a filePath for a similar prompt and it doesn't have any issues searching the symbol through LSP tools
Plugins
No response
OpenCode version
1.15.12
Steps to reproduce
- Replicate the opencode.json as above
- OPENCODE_EXPERIMENTAL_LSP_TOOL=true opencode
- Prompt to find any python / cpp symbol, its implementation and references
Screenshot and/or share link
No response
Operating System
Ubuntu 24.04.4 LTS
Terminal
VSCode terminal
Description
I am trying to get LSP working for my repository with opencode. I have clangd and pyright server setup as follows in my opencode.json
I am seeing a couple of issues:
OPENCODE_EXPERIMENTAL_LSP_TOOL=trueexplicitly set when running opencode, the agent never tries to use LSP tools and always defaults togrepOPENCODE_EXPERIMENTAL_LSP_TOOL=true, the agent tries to use LSP tools but always failsExample prompt:
Example response
I wonder why
filePathbeing set to workspace root directory in the LSP query and if thats causes what is causing the issue. I have similar server setup with Copilot CLI under.github/lsp.jsonand don't see it specifying afilePathfor a similar prompt and it doesn't have any issues searching the symbol through LSP toolsPlugins
No response
OpenCode version
1.15.12
Steps to reproduce
Screenshot and/or share link
No response
Operating System
Ubuntu 24.04.4 LTS
Terminal
VSCode terminal