Skip to content

feat(lsp): add multi-server support to CodeMirror LSP client - #2627

Merged
bajrangCoder merged 5 commits into
mainfrom
feat/multi-lsp-client
Aug 5, 2026
Merged

feat(lsp): add multi-server support to CodeMirror LSP client#2627
bajrangCoder merged 5 commits into
mainfrom
feat/multi-lsp-client

Conversation

@bajrangCoder

Copy link
Copy Markdown
Member

Summary

Vendor @codemirror/lsp-client into packages/lsp-client and add support
for attaching multiple independent language servers to a single CodeMirror
editor.

Implementation

  • Add multiple LSPClient bindings per EditorView
  • Add server priority and per-feature provider selection
  • Maintain independent synchronization state for each client
  • Aggregate results from compatible providers:
    • completions
    • hover
    • diagnostics
    • code actions
    • references
    • document colors
    • inlay hints
  • Route single-owner operations to the highest-priority capable server:
    • formatting
    • rename
    • definitions and navigation
    • signature help
    • document symbols
  • Preserve diagnostics from every attached server
  • Isolate provider failures so one server cannot suppress results from others
  • Clean up client-specific state when a server is detached

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR extends Acode’s CodeMirror LSP integration to support multiple independently configured language servers per editor.

  • Adds priority-based provider selection for single-owner operations.
  • Aggregates compatible results such as diagnostics, code actions, references, colors, and inlay hints.
  • Tracks provider identity so follow-up operations are routed back to the server that produced each result.
  • Keeps synchronization and cleanup state isolated by client.

Confidence Score: 5/5

The PR appears safe to merge because the previously reported diagnostics opt-out bypass is fixed and no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
src/cm/lsp/clientManager.ts Attaches multiple prioritized client bindings, passes per-feature enablement into each plugin, and clears client-owned diagnostics during detach and disposal.
src/cm/lsp/diagnostics.ts Separates diagnostics by client and consistently filters pull, push, synchronization, and rendering paths through diagnostics feature enablement.
src/cm/lsp/codeActions.ts Aggregates actions from capable providers while retaining the originating plugin for resolution and execution.
src/cm/lsp/documentColors.ts Aggregates color results and retains provider identity for subsequent color-presentation requests.
src/cm/lsp/inlayHints.ts Aggregates and deduplicates hints from all enabled, capable providers.
src/cm/lsp/serverRegistry.ts Sanitizes server priority and returns matching servers in descending priority order.
tests/unit/lspMultiClient.test.js Covers multi-provider selection and aggregation, including disabled diagnostics synchronization and rejection of pull and push diagnostics.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  E[CodeMirror EditorView] --> R[Server registry ordered by priority]
  R --> P1[LSP binding: server A]
  R --> P2[LSP binding: server B]
  P1 --> A[Aggregate compatible results]
  P2 --> A
  P1 --> S[Select highest-priority capable provider]
  P2 --> S
  A --> F[Diagnostics, actions, references, colors, hints]
  S --> O[Formatting, rename, navigation, symbols]
  P1 --> C[Per-client synchronization and cleanup]
  P2 --> C
Loading

Reviews (3): Last reviewed commit: "fix" | Re-trigger Greptile

Comment thread src/cm/lsp/diagnostics.ts Outdated
@bajrangCoder

This comment was marked as outdated.

@bajrangCoder

This comment was marked as outdated.

@bajrangCoder
bajrangCoder added this pull request to the merge queue Aug 5, 2026
Merged via the queue into main with commit 9a162bf Aug 5, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Aug 5, 2026
@bajrangCoder
bajrangCoder deleted the feat/multi-lsp-client branch August 5, 2026 18:18
gat0sy added a commit to gat0sy/Acode that referenced this pull request Aug 6, 2026
…m upstream multi-server

Upstream's multi-server LSP refactor (Acode-Foundation#2627) introduced three regressions
while merging into feat/lsp-improvements.

1. TDZ on `displayedView` in rename.ts and codeActions.ts
   The open-file path referenced `displayedView` before it was declared
     and incorrectly used `safeLspPositionToOffset()` instead of
       `mapping.mapPosition()`. Restored the intended behavior:
         - open files   -> `view` + `mapping.mapPosition()`
           - closed files -> `displayedView` + `safeLspPositionToOffset()`

          2. `plugin.docToHTML is not a function` in tooltipExtensions.ts
             The hover tooltip captured the wrong `plugin` instance. Fixed it to use
               `results[index].plugin` and `results[index].result.contents`, and render
                 the generated HTML through a wrapper `<div>` using `.innerHTML`.

                3. RangeError on EOF positions in rename/codeAction fallbacks
                   Some LSP servers legitimately send `line: doc.lines, character: 0`
                     to represent EOF. `lspPositionToOffset()` throws in this case because
                       it doesn't clamp positions. Replaced it with
                         `safeLspPositionToOffset()` from `textEditUtils.ts`, restoring
                           bounds-safe position handling.

                          These fixes preserve the upstream multi-server architecture while
                          restoring the safety guarantees that were lost during the merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant