How to get opencode to use LSP?
I understand there's ootb support for TS and go, but I don't seem to be able to benefit from it.
the way it works is when edit calls are made and it introduces an error we send those errors back to the LLM
if you suspect it's not working you can try the following command opencode debug lsp diagnostics ./path/to/file/with/error.ts
No additional configuration for LSP support (as described here https://pkg.go.dev/github.com/sst/opencode#readme-lsp-language-server-protocol) is required?
Bumping this question ^ I'd like to hook in a custom LSP (Lexical for Elixir), and it seems the lsp key is not accepted in opencode.json. Maybe this feature is in flux?
No additional configuration for LSP support (as described here https://pkg.go.dev/github.com/sst/opencode#readme-lsp-language-server-protocol) is required?
this is the other opencode; @thdxr will add custom lsp config soon
Just FYI, the docs I found were linked from this repo. It popped up when I searched for LSP: https://opencode.ai/docs/lsp-servers
Since it's not linked in the menu, I figured it probably was something still being worked on. You're doing great work guys; thanks so much.
Just FYI, the docs I found were linked from this repo. It popped up when I searched for LSP: https://opencode.ai/docs/lsp-servers
Since it's not linked in the menu, I figured it probably was something still being worked on. You're doing great work guys; thanks so much.
That was irritating me too ... the linked documentation does not fit to the sst/opencode source. for instance the documentation refers to ~/.config/opencode/opencode.json as config file which is wrong for the sst/opencode (it is ~/.config/opencode/config.json).
This is not working for me. I do the following:
- Ask Claude Sonnet 4 to deliberately edit a file and introduce an error.
- It does this and tells me that it is not being passed any lsp diagnostics
- I open the file in NeoVim and confirm that Claude has indeed added an error, which is being highlighted as such by the typescript lsp running in NeoVim
- I run opencode debug lsp diagnostics ./path/to/file/with/error.ts and get the output below, which looks fine to me:
opencode debug lsp diagnostics ./src/config/config.ts { "/home/david/projects/grace/packages/grace-core/src/config/config.ts": [ { range: [Object ...], message: "Type 'number' is not assignable to type 'string'.", severity: 1, code: 2322, source: "typescript", }, { range: [Object ...], message: "'z' is declared but its value is never read.", severity: 4, code: 6133, source: "typescript", }, { range: [Object ...], message: "'invalidCode' is declared but its value is never read.", severity: 4, code: 6133, source: "typescript", } ], }
This is not working for me. I do the following:
- Ask Claude Sonnet 4 to deliberately edit a file and introduce an error.
- It does this and tells me that it is not being passed any lsp diagnostics
- I open the file in NeoVim and confirm that Claude has indeed added an error, which is being highlighted as such by the typescript lsp running in NeoVim
- I run opencode debug lsp diagnostics ./path/to/file/with/error.ts and get the output below, which looks fine to me:
opencode debug lsp diagnostics ./src/config/config.ts { "/home/david/projects/grace/packages/grace-core/src/config/config.ts": [ { range: [Object ...], message: "Type 'number' is not assignable to type 'string'.", severity: 1, code: 2322, source: "typescript", }, { range: [Object ...], message: "'z' is declared but its value is never read.", severity: 4, code: 6133, source: "typescript", }, { range: [Object ...], message: "'invalidCode' is declared but its value is never read.", severity: 4, code: 6133, source: "typescript", } ], }
Same. It's wried that when I run opencode debug lsp diagnostics <file path> it got me the issues I'm expecting, but when I use the program and even explicitly ask about any issues on that file using LSP, it doesn't report anything that is reported from the debug lsp command. Instead, it fallbacks to run tsc --noEmit ... command.
@thdxr any clue?
I tried this on the Pet.java file, which has a syntax error:
> opencode debug lsp diagnostics ./src/main/java/org/springframework/samples/petclinic/owner/Pet.java
{}
The result is an empty json?
the way it works is when edit calls are made and it introduces an error we send those errors back to the LLMif you suspect it's not working you can try the following command
opencode debug lsp diagnostics ./path/to/file/with/error.ts
Just curious how its different from calling tsc or any other cli tool to get errors? The issue is performance? You dont need to build go project for example, etc