|
9 | 9 | serverCompletion, |
10 | 10 | serverDiagnostics, |
11 | 11 | } from "@codemirror/lsp-client"; |
12 | | -import { EditorState, Extension, MapMode } from "@codemirror/state"; |
| 12 | +import { EditorState, Extension, Facet, MapMode } from "@codemirror/state"; |
13 | 13 | import { EditorView, keymap } from "@codemirror/view"; |
14 | 14 | import lspStatusBar from "components/lspStatusBar"; |
15 | 15 | import notificationManager from "lib/notificationManager"; |
@@ -48,6 +48,13 @@ import type { |
48 | 48 | } from "./types"; |
49 | 49 | import AcodeWorkspace from "./workspace"; |
50 | 50 |
|
| 51 | +export const lspCompletionEnabled = Facet.define<boolean, boolean>({ |
| 52 | + // File-level marker used by the autocomplete override path. If any attached |
| 53 | + // server exposes completion, keep the shared LSP completion source available. |
| 54 | + // Per-server completion opt-outs do not make this a per-server gate. |
| 55 | + combine: (values) => values.some(Boolean), |
| 56 | +}); |
| 57 | + |
51 | 58 | function asArray<T>(value: T | T[] | null | undefined): T[] { |
52 | 59 | if (!value) return []; |
53 | 60 | return Array.isArray(value) ? value : [value]; |
@@ -354,6 +361,9 @@ export class LspClientManager { |
354 | 361 | normalizedUri, |
355 | 362 | targetLanguageId, |
356 | 363 | ); |
| 364 | + if (server.clientConfig?.builtinExtensions?.completion !== false) { |
| 365 | + lspExtensions.push(lspCompletionEnabled.of(true)); |
| 366 | + } |
357 | 367 | const aliases = |
358 | 368 | originalUri && originalUri !== normalizedUri ? [originalUri] : []; |
359 | 369 | clientState.attach(normalizedUri, view as EditorView, aliases); |
|
0 commit comments