Skip to content

How to get opencode to use LSP? #711

Closed as not planned
Closed as not planned

Description

@nitsanavni

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

Activity

  1. self-assigned this
    on Jul 5, 2025
  2. thdxr commented on Jul 5, 2025

    @thdxr
    Member

    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

  3. olk commented on Jul 13, 2025

    @olk

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

  4. giddie commented on Jul 18, 2025

    @giddie

    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?

  5. adamdotdevin commented on Jul 18, 2025

    @adamdotdevin
    Member

    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

  6. giddie commented on Jul 18, 2025

    @giddie

    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.

  7. olk commented on Jul 18, 2025

    @olk

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

  8. davidfriar1 commented on Jul 19, 2025

    @davidfriar1

    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", } ], }

  9. alvis commented on Aug 9, 2025

    @alvis

    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?

  10. jgordijn-ah commented on Dec 20, 2025

    @jgordijn-ah

    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?

  11. istarkov commented on Dec 21, 2025

    @istarkov
    Contributor

    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

  12. finnzio commented on Dec 29, 2025

    @finnzio

    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.

  13. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  14. uloco commented on Apr 28, 2026

    @uloco

    still no way to enable the lsp for me in typescript. it is not auto enabled and I have no idea why. opencode debug lsp diagnostics ./path/to/file does return {} although neovim lsp reports issues in the file.

  15. LouiFi commented on May 4, 2026

    @LouiFi

    Hi, I found a fix where I used typescript-language-server locally with bun. Now the LSP works :

    Here is my config, hope it will work for you :

    {
      "$schema": "https://opencode.ai/config.json",
      "lsp": {
        "typescript": {
          "disabled": false,
          "command": [
            "bun",
            "run",
            "--bun",
            "typescript-language-server",
            "--stdio"
          ],
          "initialization": {
            "preferences": {
              "importModuleSpecifierPreference": "relative"
            }
          }
        }
      }
    }
    
  16. kleberm91 commented on May 18, 2026

    @kleberm91

    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?

    I think this is caused by a timeout. When JDTLS starts it does a build (Maven/Gradle) and other setup stuff. That takes quite a bit depending on your project size. AFAIU OpenCode has a timeout of 10s, which is too short. I'm currently experimenting with running JDTLS outside OpenCode and have it connect to it instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions