Skip to content

Commit a6f53da

Browse files
authored
feat: add setting to toggle language package completion (Acode-Foundation#2361)
1 parent 657e87c commit a6f53da

36 files changed

Lines changed: 132 additions & 9 deletions

src/cm/lsp/clientManager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
serverCompletion,
1010
serverDiagnostics,
1111
} from "@codemirror/lsp-client";
12-
import { EditorState, Extension, MapMode } from "@codemirror/state";
12+
import { EditorState, Extension, Facet, MapMode } from "@codemirror/state";
1313
import { EditorView, keymap } from "@codemirror/view";
1414
import lspStatusBar from "components/lspStatusBar";
1515
import notificationManager from "lib/notificationManager";
@@ -48,6 +48,13 @@ import type {
4848
} from "./types";
4949
import AcodeWorkspace from "./workspace";
5050

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+
5158
function asArray<T>(value: T | T[] | null | undefined): T[] {
5259
if (!value) return [];
5360
return Array.isArray(value) ? value : [value];
@@ -354,6 +361,9 @@ export class LspClientManager {
354361
normalizedUri,
355362
targetLanguageId,
356363
);
364+
if (server.clientConfig?.builtinExtensions?.completion !== false) {
365+
lspExtensions.push(lspCompletionEnabled.of(true));
366+
}
357367
const aliases =
358368
originalUri && originalUri !== normalizedUri ? [originalUri] : [];
359369
clientState.attach(normalizedUri, view as EditorView, aliases);

src/lang/ar-ye.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "لن تتم مزامنة عملية الشراء هذه مع حساب Acode الخاص بك. استخدم نفس حساب Google في متجر Play لاستعادة عملية الشراء.",
745745
"confirm-login": "لم تقم بتسجيل الدخول إلى Acode، هل تريد تسجيل الدخول الآن؟",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/be-by.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "Гэтая пакупка не будзе сінхранізавана з вашым уліковым запісам Acode. Выкарыстоўвайце той жа ўліковы запіс Google у Play Store для аднаўлення пакупкі.",
745745
"confirm-login": "Вы не ўвайшлі ў Acode, увайсці зараз?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/bn-bd.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "এই ক্রয়টি আপনার Acode অ্যাকাউন্টের সাথে সিঙ্ক হবে না। আপনার ক্রয় পুনরুদ্ধার করতে প্লে স্টোরে একই Google অ্যাকাউন্ট ব্যবহার করুন।",
745745
"confirm-login": "আপনি Acode-এ সাইন ইন করেননি, এখন সাইন ইন করবেন?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/cs-cz.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "Tento nákup nebude synchronizován s vaším účtem Acode. Pro obnovení nákupu použijte stejný účet Google v Obchodě Play.",
745745
"confirm-login": "Nejste přihlášeni do Acode, přihlásit se nyní?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/de-de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "Dieser Kauf wird nicht mit Ihrem Acode-Konto synchronisiert. Verwenden Sie dasselbe Google-Konto im Play Store, um Ihren Kauf wiederherzustellen.",
745745
"confirm-login": "Sie sind nicht bei Acode angemeldet, jetzt anmelden?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/en-us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"add path": "Add path",
136136
"live autocompletion": "Live autocompletion",
137137
"local word completion": "Local word completion",
138+
"language package completion": "Language package completion",
138139
"auto close tags": "Auto close tags",
139140
"auto rename tags": "Auto rename tags",
140141
"file properties": "File properties",
@@ -687,6 +688,7 @@
687688
"settings-info-editor-lint-gutter": "Show diagnostics and lint markers in the gutter.",
688689
"settings-info-editor-live-autocomplete": "Show suggestions while you type.",
689690
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
691+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
690692
"settings-info-editor-auto-close-tags": "Automatically insert closing tags in HTML, XML, Vue, Angular, and PHP template files.",
691693
"settings-info-editor-auto-rename-tags": "Rename the matching opening or closing tag while editing HTML-like tags.",
692694
"settings-info-editor-rainbow-brackets": "Color matching brackets by nesting depth.",

src/lang/es-sv.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "Esta compra no se sincronizará con tu cuenta de Acode. Usa la misma cuenta de Google en Play Store para restaurar tu compra.",
745745
"confirm-login": "No has iniciado sesión en Acode, ¿iniciar sesión ahora?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/fr-fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "Cet achat ne sera pas synchronisé avec votre compte Acode. Utilisez le même compte Google dans le Play Store pour restaurer votre achat.",
745745
"confirm-login": "Vous n'êtes pas connecté à Acode, vous connecter maintenant ?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

src/lang/he-il.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,9 @@
744744
"iap-pro-purchase-warning": "רכישה זו לא תסונכרן עם חשבון Acode שלך. השתמש באותו חשבון Google בחנות Play כדי לשחזר את הרכישה שלך.",
745745
"confirm-login": "אינך מחובר ל-Acode, להתחבר עכשיו?",
746746
"local word completion": "Local word completion",
747+
"language package completion": "Language package completion",
747748
"settings-info-editor-local-word-completion": "Suggest words from the current file.",
749+
"settings-info-editor-language-completion": "Suggest keywords, snippets, and other completions from CodeMirror language packages.",
748750
"terminal:failsafe": "FailSafe mode",
749751
"terminal:failsafe-info": "Start terminal with system shell",
750752
"auto rename tags": "Auto rename tags",

0 commit comments

Comments
 (0)