Skip to content

How to configure LSP? #7405

Closed as not planned
Closed as not planned

Description

@Suaig

Question

I use opencode for embedded development. and I found LSP report many error and warning to AI assistant.
and assistant always want to fix it. but it is LSP error. LSP haven't found them.
Like below:

Error [5:10] 'FreeRTOS.h' file not found
Error [27:8] Unknown type name 'w25qxx_io_t'
Error [47:18] Call to undeclared library function 'strlen' with type 'unsigned long long (const char *)'; ISO C99 and later do not support implicit function declarations

So my question is how to configure LSP make the LSP report correct information to AI assistant. or can we disable this report?

Activity

  1. github-actions commented on Jan 9, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. zbynekwinkler commented on Jan 12, 2026

    @zbynekwinkler

    I was wondering as well. The docs say clangd is used as the LSP for C++ projects. I have tried adding .clangd config file into my project root with the contents

    CompileFlags:
      CompilationDatabase: build/Debug

    and I've finally fixed this issue for myself. For reference see https://clangd.llvm.org/config.html#compilationdatabase

  3. mmsaki commented on Mar 8, 2026

    @mmsaki

    start opencode with

    OPENCODE_EXPERIMENTAL_LSP_TOOL=true opencode
  4. BLumia commented on Apr 1, 2026

    @BLumia

    Based on current codebase, one can configure clangd using the following config:

    {
      "$schema": "https://opencode.ai/config.json",
      "lsp": {
        "clangd": {
          "command": ["C:\\msys64\\ucrt64\\bin\\clangd.exe", "--background-index", "--clang-tidy"]
        }
      }
    }

    You can use a project-level opencode.jsonc to override the global config if your different projects uses different clangd and/or with different clangd configuration. My own use-case is not embedded development but at least for my own use-case (MSYS2 C++ development) it works as intended.

  5. JinkaiNiu commented on May 23, 2026

    @JinkaiNiu

    LSP diagnostics are fed to the AI assistant to help it understand your code — but if a particular LSP server is producing noisy or incorrect diagnostics (like missing headers or unknown types for embedded development), you can configure or disable it.

    To disable LSP entirely:

    { "lsp": false }

    To disable a specific LSP server (e.g. clangd which is likely causing your C errors):

    {
      "lsp": {
        "clangd": { "disabled": true }
      }
    }

    To keep LSP enabled but configure it, you can pass initialization options or environment variables. For clangd specifically, you might want to configure your compile commands (compile_commands.json) to fix the missing header errors at the source.

    For full details:
    https://opencode.ai/docs/lsp/

  6. rekram1-node commented on Jun 23, 2026

    @rekram1-node
    Collaborator

    Automated: closing question issues.

    GitHub Issues are for bug reports and feature requests only — questions / support are no longer tracked here.

    If this is a bug or feature request, please open a new issue with the appropriate template.

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