Skip to content

Kotlin LSP support #3116

Description

@Melodeiro

There are not that bad LSP server for kotlin. I'm struggling to connect it (im on a windows), maybe im doing something wrong. But having a first-class support for it would be great: https://github.com/Kotlin/kotlin-lsp

Problem when im trying to connect it on windows is that opencode sends wrong file paths to it, like file:///C:\dir\file, or something like that. I tried to use WSL, but it doesn't responds to queries. Or does latter means, that Kotlin LSP just isn't ready for opencode yet? Not sure that it supports all necessary functions right now

Activity

  1. self-assigned this
    on Oct 12, 2025
  2. rekram1-node commented on Oct 12, 2025

    @rekram1-node
    Collaborator

    first class support makes sense, as for lsp file path issues that may be an issue we have with windows…

    @itsrainingmani have u noticed any lsp issues on windows?

  3. iwauo commented on Oct 17, 2025

    @iwauo
    Contributor

    I think kotlin‑lsp works with opencode.ai on Unix‑like systems, including WSL.
    I use it on both Linux and macOS with the following setup:

    1. Follow the installation instructions at https://github.com/Kotlin/kotlin-lsp.
    2. Add the following configuration to your opencode.json:
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "llama-cpp": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Llama.cpp (local)",
          "options": {
            "baseURL": "http://localhost:11434/v1"
          },
          "models": {
            "gpt-oss-20B": {
              "name": "unsloth/gpt-oss-20b-GGUF:Q4_K_M"
            }
          }
        }
      },
      "lsp": {
    +    "kotlin-lsp": {
    +     "command": ["kotlin-lsp"],
    +      "extensions": [".kt"]
    +    }
      }
    }
  4. Melodeiro commented on Oct 17, 2025

    @Melodeiro
    Author

    Hmm, will try. When i tried to specify kotlin-lsp.sh command i got no response. Or maybe due to --stdio parameter...

  5. johannesrave commented on Oct 19, 2025

    @johannesrave

    the lsp generally works but i think opencode hasn't yet implemented pull-style diagnostics. the same was the case for the helix editor (which added support just three weeks ago, the pull-flow appears to be rather new)

  6. pskwr commented on Nov 27, 2025

    @pskwr

    Has anyone managed to get Kotlin LSP working in opencode?

    I tried both:

    • kotlin-lsp
    • fwcd/kotlin-language-server

    by configuring them as an lsp in my opencode.json (based on https://opencode.ai/docs/lsp/#custom-lsp-servers), but I couldn’t get either of them to work.

  7. hoota commented on Jan 12, 2026

    @hoota

    Any updates on this feature request?
    Documentation said kotlin-lsp is now auto installed, but it seems it doesn't work.
    At least opencode lsp debug diagnose responses with empty json object - {}

  8. mrclrchtr commented on Feb 2, 2026

    @mrclrchtr

    how can we check, if it is working as expected?

    Edit:
    Found the following out with

      "lsp": {
        "kotlin-ls": {
          "disabled": true
        },
        "kotlin-lsp": {
          "command": ["kotlin-lsp", "--stdio"],
          "extensions": [".kt", ".kts"]
        }
      }
    

    installed https://github.com/Kotlin/kotlin-lsp via brew

    Opencode LSP Tool Command Input Type Works? What I observed
    Workspace symbol search opencode debug lsp symbols string Partially Command runs, but returns [] for Kotlin queries (TheClass, FQN).
    Document symbols opencode debug lsp document-symbols (must be URL) Yes Works with file:///…/TheClass.kt; fails with plain file path (cannot be parsed as a URL). Returns full symbol tree.
    Diagnostics opencode debug lsp diagnostics path Yes Works with plain file path; for tested Kotlin file returns {} (no diagnostics surfaced).

    BUT: I couldn't get opencode to use the information. It doesn't even notice that kotlin-lsp is there, even though it's displayed in the sidebar:

    Image
  9. mrclrchtr commented on Feb 2, 2026

    @mrclrchtr

    I went through the code and... it's a mess. I'm seriously considering not using opencode anymore :D

    But what I found out, for example, is that the cos are wrong. It definitely uses kotlin-lsp () and not kotlin-ls.

    I'll try to fix a few bugs, update the docs, and create a PR for it.

    Here's a summary after the analysis:

    - Built-in Kotlin LSP is Kotlin/kotlin-lsp (JetBrains), not fwcd: the built-in server is id: "kotlin-ls" but it downloads from https://api.github.com/repos/Kotlin/kotlin-lsp/releases/latest and launches kotlin-lsp.sh/kotlin-lsp.cmd. See packages/opencode/src/lsp/server.ts:1231.
    - fwcd/kotlin-language-server is not used anywhere: repo search finds no references to fwcd / kotlin-language-server (only the docs/config examples from the issue discussion; not in code).
    - Why diagnostics don’t reach the agent:
          - The LSP client only consumes push diagnostics via textDocument/publishDiagnostics (packages/opencode/src/lsp/client.ts:52).
        - There is no implementation for pull diagnostics (textDocument/diagnostic / workspace/diagnostic) in packages/opencode/src/lsp/*, so servers that primarily use pull-diagnostics will produce {} in LSP.diagnostics() even if they’re “working”.
        - Even when diagnostics exist, they’re only appended to tool outputs after write-like actions (write/edit/apply_patch) (packages/opencode/src/tool/write.ts:56, packages/opencode/src/tool/edit.ts:132). A normal read just “warms” LSP without waiting (packages/opencode/src/tool/read.ts:132).
    - Why symbol info doesn’t reach the agent (this one is a hard blocker):
        - The HTTP route that should expose workspace symbol search is currently stubbed to always return [] (packages/opencode/src/server/routes/file.ts:86).
        - The lsp tool’s workspaceSymbol operation ignores the user query and calls LSP.workspaceSymbol("") (packages/opencode/src/tool/lsp.ts:72), so even direct tool usage is effectively broken for searching.
    - Docs are misleading/out-of-date for Kotlin naming: packages/web/src/content/docs/lsp.mdx:30 lists kotlin-ls as the built-in server, but doesn’t mention it actually installs/launches kotlin-lsp from Kotlin/kotlin-lsp—easy to interpret as a different server.
    
    
  10. github-actions commented on Apr 4, 2026

    @github-actions
    Contributor

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

  11. kyboi commented on Apr 8, 2026

    @kyboi

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

    Reopen this, it should use the official Kotlin LSP where possible and in an efficient manner

  12. lowlyocean commented on Apr 20, 2026

    @lowlyocean

    Reopen this issue, it's still a problem

  13. hildebrandt commented on Apr 20, 2026

    @hildebrandt

    I can confirm. Kotlin LSP isn’t working for me either. I tried the default Kotlin LSP configuration (kotlin-ls) as well as a custom setup using https://github.com/Kotlin/kotlin-lsp, and neither worked. Please reopen this issue.

  14. reopened this on Apr 22, 2026
  15. assigned and unassigned on Apr 22, 2026
  16. Hona commented on Apr 22, 2026

    @Hona
    Member
  17. Hona commented on Apr 22, 2026

    @Hona
    Member

    before and after for the debug command

    on dev right now it is empty, on my branch we can see the error diags

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions