How to get opencode to use LSP? #514

Open
opened 2026-02-16 17:27:08 -05:00 by yindo · 11 comments
Owner

Originally created by @nitsanavni on GitHub (Jul 5, 2025).

Originally assigned to: @thdxr on GitHub.

I understand there's ootb support for TS and go, but I don't seem to be able to benefit from it.

Originally created by @nitsanavni on GitHub (Jul 5, 2025). Originally assigned to: @thdxr on GitHub. I understand there's ootb support for TS and go, but I don't seem to be able to benefit from it.
Author
Owner

@thdxr commented on GitHub (Jul 5, 2025):

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

@thdxr commented on GitHub (Jul 5, 2025): the way it works is when edit calls are made and it introduces an error we send those errors back to the LLM<br><br>if you suspect it's not working you can try the following command `opencode debug lsp diagnostics ./path/to/file/with/error.ts`
Author
Owner

@olk commented on GitHub (Jul 13, 2025):

No additional configuration for LSP support (as described here https://pkg.go.dev/github.com/sst/opencode#readme-lsp-language-server-protocol) is required?

@olk commented on GitHub (Jul 13, 2025): No additional configuration for LSP support (as described here https://pkg.go.dev/github.com/sst/opencode#readme-lsp-language-server-protocol) is required?
Author
Owner

@giddie commented on GitHub (Jul 18, 2025):

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?

@giddie commented on GitHub (Jul 18, 2025): 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?
Author
Owner

@adamdotdevin commented on GitHub (Jul 18, 2025):

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

@adamdotdevin commented on GitHub (Jul 18, 2025): > 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
Author
Owner

@giddie commented on GitHub (Jul 18, 2025):

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.

@giddie commented on GitHub (Jul 18, 2025): 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.
Author
Owner

@olk commented on GitHub (Jul 18, 2025):

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).

@olk commented on GitHub (Jul 18, 2025): > 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).
Author
Owner

@davidfriar1 commented on GitHub (Jul 19, 2025):

This is not working for me. I do the following:

  1. Ask Claude Sonnet 4 to deliberately edit a file and introduce an error.
  2. It does this and tells me that it is not being passed any lsp diagnostics
  3. 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
  4. 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", } ], }

@davidfriar1 commented on GitHub (Jul 19, 2025): This is not working for me. I do the following: 1. Ask Claude Sonnet 4 to deliberately edit a file and introduce an error. 2. It does this and tells me that it is not being passed any lsp diagnostics 3. 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 4. 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", } ], }`
Author
Owner

@alvis commented on GitHub (Aug 9, 2025):

This is not working for me. I do the following:

  1. Ask Claude Sonnet 4 to deliberately edit a file and introduce an error.
  2. It does this and tells me that it is not being passed any lsp diagnostics
  3. 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
  4. 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?

@alvis commented on GitHub (Aug 9, 2025): > This is not working for me. I do the following: > > 1. Ask Claude Sonnet 4 to deliberately edit a file and introduce an error. > 2. It does this and tells me that it is not being passed any lsp diagnostics > 3. 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 > 4. 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?
Author
Owner

@jgordijn-ah commented on GitHub (Dec 20, 2025):

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?

@jgordijn-ah commented on GitHub (Dec 20, 2025): 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?
Author
Owner

@istarkov commented on GitHub (Dec 21, 2025):

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

@istarkov commented on GitHub (Dec 21, 2025): > 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
Author
Owner

@StereoApp commented on GitHub (Dec 29, 2025):

I think we should add the Node-related executables directory to the environment, for example:

export PATH=/home/user/.local/share/opencode/bin/node_modules/.bin:$PATH

After setting this, my Vue diagnostics can run properly. Previously, it was failing with a "command not found" error when LLM call lsp_diagnostics.

@StereoApp commented on GitHub (Dec 29, 2025): I think we should add the Node-related executables directory to the environment, for example: export PATH=/home/user/.local/share/opencode/bin/node_modules/.bin:$PATH After setting this, my Vue diagnostics can run properly. Previously, it was failing with a "command not found" error when LLM call lsp_diagnostics.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#514