[PR #4543] fix: replace ruby-lsp with rubocop for better LSP performance #11011

Closed
opened 2026-02-16 18:15:47 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4543

State: closed
Merged: Yes


Problem

The current ruby-lsp implementation has two critical issues:

  1. Invalid LSP argument: ruby-lsp is spawned with ["--stdio"] which is not a valid argument for ruby-lsp. The LSP server should start automatically without this flag.
ruby-lsp --stdio
invalid option: --stdio

Usage: ruby-lsp [options]
        --version                    Print ruby-lsp version
        --debug                      Launch the Ruby LSP with a debugger attached
        --time-index                 Measure the time it takes to index the project
        --branch [BRANCH]            Launch the Ruby LSP using the specified branch rather than the release version
        --doctor                     Run troubleshooting steps
        --use-launcher               [EXPERIMENTAL] Use launcher mechanism to handle missing dependencies gracefully
    -h, --help                       Print this help
  1. Startup timeout: ruby-lsp takes ~2.65 seconds to initialize, and sometimes exceeds opencode's 3-second LSP startup timeout, causing Ruby files to never receive LSP diagnostics.

Solution

Replace ruby-lsp with rubocop's LSP mode:

  • Startup time: ~0.58s (78% faster, well under the 3-second timeout)
  • Minimalistic approach: rubocop focuses on what matters for opencode's LLM workflow:
    • Linting errors and warnings
    • Formatting issues
    • Syntax errors
  • No bloat: Unlike ruby-lsp, rubocop doesn't include unnecessary IDE features:
    • No autocomplete (LLM handles this)
    • No go-to-definition (LLM provides context)
    • No rename refactoring (LLM suggests refactorings)
    • No documentation hovers (LLM provides documentation)

Changes

  • Modified packages/opencode/src/lsp/server.ts:
    • Replaced ruby-lsp binary with rubocop
    • Changed spawn arguments from ["--stdio"] to ["--lsp"]
    • Updated gem installation and logging
    • Kept LSP ID as "ruby-lsp" for backward compatibility
  • Updated packages/web/src/content/docs/lsp.mdx:
    • Changed LSP table entry to ruby-lsp (rubocop) to clarify the implementation

Backward Compatibility

Users with existing opencode.jsonc configs will not be affected:

  • The LSP ID remains "ruby-lsp" internally
  • Existing "ruby-lsp" overrides in config will continue to work
  • Transparent upgrade with no breaking changes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4543 **State:** closed **Merged:** Yes --- ## Problem The current ruby-lsp implementation has two critical issues: 1. **Invalid LSP argument**: ruby-lsp is spawned with `["--stdio"]` which is not a valid argument for ruby-lsp. The LSP server should start automatically without this flag. ``` ruby-lsp --stdio invalid option: --stdio Usage: ruby-lsp [options] --version Print ruby-lsp version --debug Launch the Ruby LSP with a debugger attached --time-index Measure the time it takes to index the project --branch [BRANCH] Launch the Ruby LSP using the specified branch rather than the release version --doctor Run troubleshooting steps --use-launcher [EXPERIMENTAL] Use launcher mechanism to handle missing dependencies gracefully -h, --help Print this help ``` 3. **Startup timeout**: ruby-lsp takes ~2.65 seconds to initialize, and sometimes exceeds opencode's 3-second LSP startup timeout, causing Ruby files to never receive LSP diagnostics. ## Solution Replace ruby-lsp with rubocop's LSP mode: - **Startup time**: ~0.58s (78% faster, well under the 3-second timeout) - **Minimalistic approach**: rubocop focuses on what matters for opencode's LLM workflow: - Linting errors and warnings - Formatting issues - Syntax errors - **No bloat**: Unlike ruby-lsp, rubocop doesn't include unnecessary IDE features: - No autocomplete (LLM handles this) - No go-to-definition (LLM provides context) - No rename refactoring (LLM suggests refactorings) - No documentation hovers (LLM provides documentation) ## Changes - Modified `packages/opencode/src/lsp/server.ts`: - Replaced ruby-lsp binary with rubocop - Changed spawn arguments from `["--stdio"]` to `["--lsp"]` - Updated gem installation and logging - Kept LSP ID as `"ruby-lsp"` for backward compatibility - Updated `packages/web/src/content/docs/lsp.mdx`: - Changed LSP table entry to `ruby-lsp (rubocop)` to clarify the implementation ## Backward Compatibility Users with existing `opencode.jsonc` configs will not be affected: - The LSP ID remains `"ruby-lsp"` internally - Existing `"ruby-lsp"` overrides in config will continue to work - Transparent upgrade with no breaking changes
yindo added the pull-request label 2026-02-16 18:15:47 -05:00
yindo closed this issue 2026-02-16 18:15:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11011