Skip to content

[FEATURE]: Export LSP functionality through @opencode-ai/plugin for custom tools #4410

Closed

Description

@markuest

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

We have very specific requirements for code changes and have built a custom tool in .opencode/tool/ for this purpose. Currently, the LSP module (packages/opencode/src/lsp/index.ts) is only available to opencode's built-in tools and cannot be accessed by custom tools created via @opencode-ai/plugin.

Built-in tools like edit, write and lsp_diagnostics use LSP functions to validate code changes:

await LSP.touchFile(filePath, true)  
const diagnostics = await LSP.diagnostics()

The lsp_diagnostics tool would be a good candidate to work around this issue, but packages/opencode/src/tool/lsp-diagnostics.txt says "do not use". When creating custom tools in .opencode/tool/, users can only import from @opencode-ai/plugin, which doesn't expose LSP functionality.

Use Case

If my reading of the source is correct, custom tools that modify code files need to:

  1. Notify the language server of file changes via LSP.touchFile()
  2. Retrieve diagnostics to validate changes via LSP.diagnostics()
  3. Format diagnostic output using LSP.Diagnostic.pretty()

Proposed Solution

Export LSP functionality through @opencode-ai/plugin to enable custom tools to:

  • Call LSP.touchFile(filepath, waitForDiagnostics) to notify language servers of file changes
  • Call LSP.diagnostics() to retrieve validation errors and warnings
  • Access LSP.Diagnostic.pretty() for formatting diagnostic output
  • Optionally access LSP.hover() for hover information

Alternative Workarounds

  • Fork opencode and add tools directly to the codebase
  • Update and use the lsp_diagnostics tool
  • Use built-in edit/write tools instead of custom editing tools (this violates our requirements)

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 17, 2025
  2. rekram1-node commented on Nov 17, 2025

    @rekram1-node
    Collaborator

    Yeah that's valid

  3. self-assigned this
    on Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions