Skip to content

Commit dac1089

Browse files
refactor(vscode, language-server): remove hybrid mode configuration (#5248)
1 parent 860ffca commit dac1089

File tree

27 files changed

+2345
-2388
lines changed

27 files changed

+2345
-2388
lines changed

Diff for: extensions/vscode/package.json

+5-56
Original file line numberDiff line numberDiff line change
@@ -254,34 +254,6 @@
254254
"default": "off",
255255
"description": "Traces the communication between VS Code and the language server."
256256
},
257-
"vue.server.hybridMode": {
258-
"type": [
259-
"boolean",
260-
"string"
261-
],
262-
"default": "auto",
263-
"enum": [
264-
"auto",
265-
"typeScriptPluginOnly",
266-
true,
267-
false
268-
],
269-
"enumDescriptions": [
270-
"Automatically detect and enable TypeScript Plugin/Hybrid Mode in a safe environment.",
271-
"Only enable Vue TypeScript Plugin but disable Hybrid Mode.",
272-
"Enable TypeScript Plugin/Hybrid Mode.",
273-
"Disable TypeScript Plugin/Hybrid Mode."
274-
],
275-
"description": "Vue language server only handles CSS and HTML language support, and tsserver takes over TS language support via TS plugin."
276-
},
277-
"vue.server.compatibleExtensions": {
278-
"type": "array",
279-
"items": {
280-
"type": "string"
281-
},
282-
"default": [],
283-
"description": "Set compatible extensions to skip automatic detection of Hybrid Mode."
284-
},
285257
"vue.server.includeLanguages": {
286258
"type": "array",
287259
"items": {
@@ -291,14 +263,6 @@
291263
"vue"
292264
]
293265
},
294-
"vue.server.maxOldSpaceSize": {
295-
"type": [
296-
"number",
297-
"null"
298-
],
299-
"default": null,
300-
"description": "Set --max-old-space-size option on server process. If you have problem on frequently \"Request textDocument/** failed.\" error, try setting higher memory(MB) on it."
301-
},
302266
"vue.doctor.status": {
303267
"type": "boolean",
304268
"default": true,
@@ -330,11 +294,6 @@
330294
"customBlocks"
331295
]
332296
},
333-
"vue.updateImportsOnFileMove.enabled": {
334-
"type": "boolean",
335-
"default": true,
336-
"description": "Enabled update imports on file move."
337-
},
338297
"vue.codeActions.enabled": {
339298
"type": "boolean",
340299
"default": true,
@@ -472,47 +431,37 @@
472431
"title": "Split <script>, <template>, <style> Editors",
473432
"category": "Vue",
474433
"icon": "images/split-editors.png"
475-
},
476-
{
477-
"command": "vue.findAllFileReferences",
478-
"title": "Find File References via Vue Language Server",
479-
"category": "Vue"
480434
}
481435
],
482436
"menus": {
483437
"editor/context": [
484438
{
485439
"command": "typescript.goToSourceDefinition",
486-
"when": "vueHybridMode && tsSupportsSourceDefinition && resourceLangId == vue",
440+
"when": "tsSupportsSourceDefinition && resourceLangId == vue",
487441
"group": "navigation@9"
488442
}
489443
],
490444
"explorer/context": [
491445
{
492446
"command": "typescript.findAllFileReferences",
493-
"when": "vueHybridMode && tsSupportsFileReferences && resourceLangId == vue",
494-
"group": "4_search"
495-
},
496-
{
497-
"command": "vue.findAllFileReferences",
498-
"when": "!vueHybridMode && resourceLangId == vue",
447+
"when": "tsSupportsFileReferences && resourceLangId == vue",
499448
"group": "4_search"
500449
}
501450
],
502451
"editor/title/context": [
503452
{
504453
"command": "typescript.findAllFileReferences",
505-
"when": "vueHybridMode && tsSupportsFileReferences && resourceLangId == vue"
454+
"when": "tsSupportsFileReferences && resourceLangId == vue"
506455
}
507456
],
508457
"commandPalette": [
509458
{
510459
"command": "typescript.reloadProjects",
511-
"when": "vueHybridMode && editorLangId == vue && typescript.isManagedFile"
460+
"when": "editorLangId == vue && typescript.isManagedFile"
512461
},
513462
{
514463
"command": "typescript.goToProjectConfig",
515-
"when": "vueHybridMode && editorLangId == vue"
464+
"when": "editorLangId == vue"
516465
},
517466
{
518467
"command": "vue.action.doctor",

Diff for: extensions/vscode/src/compatibility.ts

-55
This file was deleted.

Diff for: extensions/vscode/src/hybridMode.ts

+25-132
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,8 @@
11
import * as fs from 'node:fs';
22
import * as path from 'node:path';
3-
import { computed, executeCommand, useAllExtensions, useVscodeContext, watchEffect } from 'reactive-vscode';
3+
import { computed, useAllExtensions } from 'reactive-vscode';
44
import * as semver from 'semver';
55
import * as vscode from 'vscode';
6-
import { incompatibleExtensions, unknownExtensions } from './compatibility';
7-
import { config } from './config';
8-
9-
const extensions = useAllExtensions();
10-
11-
export const enabledHybridMode = computed(() => {
12-
if (config.server.hybridMode === 'typeScriptPluginOnly') {
13-
return false;
14-
}
15-
else if (config.server.hybridMode === 'auto') {
16-
if (
17-
incompatibleExtensions.value.length ||
18-
unknownExtensions.value.length
19-
) {
20-
return false;
21-
}
22-
else if (
23-
(vscodeTsdkVersion.value && !semver.gte(vscodeTsdkVersion.value, '5.3.0')) ||
24-
(workspaceTsdkVersion.value && !semver.gte(workspaceTsdkVersion.value, '5.3.0'))
25-
) {
26-
return false;
27-
}
28-
return true;
29-
}
30-
return config.server.hybridMode;
31-
});
32-
33-
export const enabledTypeScriptPlugin = computed(() => {
34-
return (
35-
enabledHybridMode.value ||
36-
config.server.hybridMode === 'typeScriptPluginOnly'
37-
);
38-
});
396

407
const vscodeTsdkVersion = computed(() => {
418
const nightly = extensions.value.find(
@@ -68,107 +35,33 @@ const workspaceTsdkVersion = computed(() => {
6835
}
6936
});
7037

71-
export function useHybridModeTips() {
72-
useVscodeContext('vueHybridMode', enabledHybridMode);
38+
const extensions = useAllExtensions();
7339

74-
watchEffect(() => {
75-
if (config.server.hybridMode === 'auto') {
76-
if (
77-
incompatibleExtensions.value.length ||
78-
unknownExtensions.value.length
79-
) {
80-
vscode.window
81-
.showInformationMessage(
82-
`Hybrid Mode is disabled automatically because there is a potentially incompatible ${[
83-
...incompatibleExtensions.value,
84-
...unknownExtensions.value,
85-
].join(', ')} TypeScript plugin installed.`,
86-
'Open Settings',
87-
'Report a false positive'
88-
)
89-
.then(value => {
90-
if (value === 'Open Settings') {
91-
executeCommand(
92-
'workbench.action.openSettings',
93-
'vue.server.hybridMode'
94-
);
95-
}
96-
else if (value == 'Report a false positive') {
97-
vscode.env.openExternal(
98-
vscode.Uri.parse(
99-
'https://github.com/vuejs/language-tools/pull/4206'
100-
)
101-
);
102-
}
103-
});
104-
}
105-
else if (
106-
(vscodeTsdkVersion.value && !semver.gte(vscodeTsdkVersion.value, '5.3.0')) ||
107-
(workspaceTsdkVersion.value && !semver.gte(workspaceTsdkVersion.value, '5.3.0'))
108-
) {
109-
let msg = `Hybrid Mode is disabled automatically because TSDK >= 5.3.0 is required (VSCode TSDK: ${vscodeTsdkVersion.value}`;
110-
if (workspaceTsdkVersion.value) {
111-
msg += `, Workspace TSDK: ${workspaceTsdkVersion.value}`;
112-
}
113-
msg += `).`;
114-
vscode.window
115-
.showInformationMessage(msg, 'Open Settings')
116-
.then(value => {
117-
if (value === 'Open Settings') {
118-
executeCommand(
119-
'workbench.action.openSettings',
120-
'vue.server.hybridMode'
121-
);
122-
}
123-
});
124-
}
40+
export function checkCompatible() {
41+
for (const extension of extensions.value) {
42+
if (
43+
extension.id === 'denoland.vscode-deno'
44+
&& vscode.workspace.getConfiguration('deno').get<boolean>('enable')
45+
) {
46+
vscode.window.showWarningMessage(`The ${extension.packageJSON.displayName}(${extension.id}) extension is incompatible with the Vue extension. Please disable Deno in workspace to avoid issues.`);
12547
}
126-
else if (config.server.hybridMode && incompatibleExtensions.value.length) {
127-
vscode.window
128-
.showWarningMessage(
129-
`You have explicitly enabled Hybrid Mode, but you have installed known incompatible extensions: ${incompatibleExtensions.value.join(
130-
', '
131-
)}. You may want to change vue.server.hybridMode to "auto" to avoid compatibility issues.`,
132-
'Open Settings',
133-
'Report a false positive'
134-
)
135-
.then(value => {
136-
if (value === 'Open Settings') {
137-
executeCommand(
138-
'workbench.action.openSettings',
139-
'vue.server.hybridMode'
140-
);
141-
}
142-
else if (value == 'Report a false positive') {
143-
vscode.env.openExternal(
144-
vscode.Uri.parse(
145-
'https://github.com/vuejs/language-tools/pull/4206'
146-
)
147-
);
148-
}
149-
});
48+
if (
49+
extension.id === 'svelte.svelte-vscode'
50+
&& semver.lt(extension.packageJSON.version, '108.4.0')
51+
) {
52+
vscode.window.showWarningMessage(`The ${extension.packageJSON.displayName}(${extension.id}) extension is incompatible with the Vue extension. Please update ${extension.packageJSON.displayName} to the latest version to avoid issues.`);
15053
}
151-
});
152-
}
153-
154-
export function useHybridModeStatusItem() {
155-
const item = vscode.languages.createLanguageStatusItem(
156-
'vue-hybrid-mode',
157-
config.server.includeLanguages
158-
);
159-
160-
item.text = 'Hybrid Mode';
161-
item.detail =
162-
(enabledHybridMode.value ? 'Enabled' : 'Disabled') +
163-
(config.server.hybridMode === 'auto' ? ' (Auto)' : '');
164-
item.command = {
165-
title: 'Open Setting',
166-
command: 'workbench.action.openSettings',
167-
arguments: ['vue.server.hybridMode'],
168-
};
169-
170-
if (!enabledHybridMode.value) {
171-
item.severity = vscode.LanguageStatusSeverity.Warning;
54+
}
55+
if (
56+
(vscodeTsdkVersion.value && !semver.gte(vscodeTsdkVersion.value, '5.3.0')) ||
57+
(workspaceTsdkVersion.value && !semver.gte(workspaceTsdkVersion.value, '5.3.0'))
58+
) {
59+
let msg = `TSDK >= 5.3.0 is required (VSCode TSDK: ${vscodeTsdkVersion.value}`;
60+
if (workspaceTsdkVersion.value) {
61+
msg += `, Workspace TSDK: ${workspaceTsdkVersion.value}`;
62+
}
63+
msg += `).`;
64+
vscode.window.showWarningMessage(msg);
17265
}
17366
}
17467

0 commit comments

Comments
 (0)