Skip to content

Getting error No LSP server available for this file type. #30442

@gulshan216

Description

@gulshan216

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:

  1. Without OPENCODE_EXPERIMENTAL_LSP_TOOL=true explicitly set when running opencode, the agent never tries to use LSP tools and always defaults to grep
  2. 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

  1. Replicate the opencode.json as above
  2. OPENCODE_EXPERIMENTAL_LSP_TOOL=true opencode
  3. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions