Skip to content

Commit 9a162bf

Browse files
authored
feat(lsp): add multi-server support to CodeMirror LSP client (#2627)
* feat(lsp): support multiple language servers per editor * fix: spell * fix(lsp): honor diagnostics provider opt-out * refactor(lsp): consume standalone multi-server client * fix
1 parent 706e936 commit 9a162bf

18 files changed

Lines changed: 909 additions & 269 deletions

_typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ IZ = "IZ"
5454
shft = "shft"
5555
multline = "multline"
5656
sav = "sav"
57+
ist = "ist"

bun.lock

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 78 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"plugins": {
3232
"cordova-clipboard": {},
3333
"cordova-plugin-device": {},
34-
"cordova-plugin-file": {},
34+
"cordova-plugin-file": {
35+
"ANDROIDX_WEBKIT_VERSION": "1.4.0"
36+
},
3537
"cordova-plugin-server": {},
3638
"cordova-plugin-ftp": {},
3739
"cordova-plugin-sdcard": {},
@@ -104,6 +106,7 @@
104106
"cordova-plugin-system": "file:src/plugins/system",
105107
"cordova-plugin-websocket": "file:src/plugins/websocket",
106108
"css-loader": "^7.1.4",
109+
"happy-dom": "^20.11.1",
107110
"mini-css-extract-plugin": "^2.10.2",
108111
"path-browserify": "^1.0.1",
109112
"postcss-loader": "^8.2.1",
@@ -148,7 +151,7 @@
148151
"@codemirror/language-data": "^6.5.2",
149152
"@codemirror/legacy-modes": "^6.5.3",
150153
"@codemirror/lint": "^6.9.7",
151-
"@codemirror/lsp-client": "^6.2.5",
154+
"@codemirror/lsp-client": "github:Acode-Foundation/codemirror-lsp-client#db6930c2b6db67e14978f08ae8f5aeb149d29468",
152155
"@codemirror/search": "^6.7.1",
153156
"@codemirror/state": "^6.6.0",
154157
"@codemirror/theme-one-dark": "^6.1.3",

src/cm/colorChip.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { LSPClient } from "@codemirror/lsp-client";
12
import { LSPPlugin } from "@codemirror/lsp-client";
23
import type { Range } from "@codemirror/state";
34
import { Decoration, EditorView, WidgetType } from "@codemirror/view";
@@ -16,6 +17,8 @@ export interface ColorChipPayload {
1617
css: string;
1718
pickerSeed?: string;
1819
source: ColorChipSource;
20+
/** Originating provider for LSP color-presentation requests. */
21+
lspClient?: LSPClient;
1922
}
2023

2124
const chipState = new WeakMap<HTMLElement, ColorChipPayload>();
@@ -43,6 +46,7 @@ export class ColorChipWidget extends WidgetType {
4346
other.payload.to === this.payload.to &&
4447
other.payload.css === this.payload.css &&
4548
other.payload.source === this.payload.source &&
49+
other.payload.lspClient === this.payload.lspClient &&
4650
(other.payload.pickerSeed || "") === (this.payload.pickerSeed || "")
4751
);
4852
}
@@ -90,14 +94,10 @@ export function isViewEditable(view: EditorView): boolean {
9094
}
9195

9296
export function hasLspColorProvider(view: EditorView): boolean {
93-
const lsp = LSPPlugin.get(view) as {
94-
client?: {
95-
connected?: boolean;
96-
serverCapabilities?: { colorProvider?: boolean | object } | null;
97-
};
98-
} | null;
99-
return !!(
100-
lsp?.client?.connected && lsp.client.serverCapabilities?.colorProvider
97+
return LSPPlugin.getAll(view, "documentColor").some(
98+
(lsp) =>
99+
lsp.client.connected &&
100+
!!lsp.client.serverCapabilities?.colorProvider,
101101
);
102102
}
103103

0 commit comments

Comments
 (0)