Skip to content

Commit 31c9148

Browse files
committed
feat: upgrade volar to 2.2.0-alpha.12
1 parent 7072a2a commit 31c9148

File tree

22 files changed

+575
-580
lines changed

22 files changed

+575
-580
lines changed

extensions/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
"devDependencies": {
516516
"@types/semver": "^7.5.3",
517517
"@types/vscode": "^1.82.0",
518-
"@volar/vscode": "2.2.0-alpha.10",
518+
"@volar/vscode": "2.2.0-alpha.12",
519519
"@vue/language-core": "2.0.14",
520520
"@vue/language-server": "2.0.14",
521521
"@vue/typescript-plugin": "2.0.14",

extensions/vscode/src/common.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { DiagnosticModel, VueInitializationOptions } from '@vue/language-server';
2-
import * as vscode from 'vscode';
31
import * as lsp from '@volar/vscode';
2+
import { quickPick } from '@volar/vscode/lib/common';
3+
import type { VueInitializationOptions } from '@vue/language-server';
4+
import * as fs from 'fs';
5+
import * as path from 'path';
6+
import * as semver from 'semver';
7+
import * as vscode from 'vscode';
48
import { config } from './config';
59
import * as doctor from './features/doctor';
610
import * as nameCasing from './features/nameCasing';
711
import * as splitEditors from './features/splitEditors';
8-
import * as semver from 'semver';
9-
import * as fs from 'fs';
10-
import * as path from 'path';
11-
import { quickPick } from '@volar/vscode/lib/common';
1212

1313
let client: lsp.BaseLanguageClient;
1414

@@ -437,13 +437,8 @@ async function getInitializationOptions(
437437
hybridMode: boolean,
438438
): Promise<VueInitializationOptions> {
439439
return {
440-
diagnosticModel: enabledHybridMode ? DiagnosticModel.Pull : DiagnosticModel.Push,
441440
typescript: { tsdk: (await lsp.getTsdk(context)).tsdk },
442441
maxFileSize: config.server.maxFileSize,
443-
semanticTokensLegend: {
444-
tokenTypes: [],
445-
tokenModifiers: [],
446-
},
447442
vue: {
448443
hybridMode,
449444
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"devDependencies": {
2222
"@lerna-lite/cli": "latest",
2323
"@lerna-lite/publish": "latest",
24-
"@volar/language-service": "2.2.0-alpha.10",
24+
"@volar/language-service": "2.2.0-alpha.12",
2525
"@volar/tsl-config": "latest",
2626
"tsl": "latest",
2727
"typescript": "latest",

packages/component-meta/lib/base.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,6 @@ function createCheckerWorker(
8888
}
8989
return scriptSnapshots.get(fileName);
9090
},
91-
getLanguageId: fileName => {
92-
if (parsedCommandLine.vueOptions.extensions.some(ext => fileName.endsWith(ext))) {
93-
return 'vue';
94-
}
95-
if (parsedCommandLine.vueOptions.vitePressExtensions.some(ext => fileName.endsWith(ext))) {
96-
return 'markdown';
97-
}
98-
if (parsedCommandLine.vueOptions.petiteVueExtensions.some(ext => fileName.endsWith(ext))) {
99-
return 'html';
100-
}
101-
return vue.resolveCommonLanguageId(fileName);
102-
},
10391
scriptIdToFileName: id => id,
10492
fileNameToScriptId: id => id,
10593
};

packages/component-meta/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"directory": "packages/component-meta"
1313
},
1414
"dependencies": {
15-
"@volar/typescript": "2.2.0-alpha.10",
15+
"@volar/typescript": "2.2.0-alpha.12",
1616
"@vue/language-core": "2.0.14",
1717
"path-browserify": "^1.0.1",
1818
"vue-component-type-helpers": "2.0.14"

packages/language-core/lib/languageModule.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function getFileRegistryKey(
5151
return JSON.stringify(values);
5252
}
5353

54-
interface _Plugin extends LanguagePlugin<VueVirtualCode> {
54+
export interface _Plugin extends LanguagePlugin<VueVirtualCode> {
5555
getCanonicalFileName: (fileName: string) => string;
5656
pluginContext: Parameters<VueLanguagePlugin>[0];
5757
}
@@ -93,14 +93,19 @@ export function createVueLanguagePlugin(
9393
return {
9494
getCanonicalFileName,
9595
pluginContext,
96+
getLanguageId(scriptId) {
97+
if (vueCompilerOptions.extensions.some(ext => scriptId.endsWith(ext))) {
98+
return 'vue';
99+
}
100+
if (vueCompilerOptions.vitePressExtensions.some(ext => scriptId.endsWith(ext))) {
101+
return 'markdown';
102+
}
103+
if (vueCompilerOptions.petiteVueExtensions.some(ext => scriptId.endsWith(ext))) {
104+
return 'html';
105+
}
106+
},
96107
createVirtualCode(fileId, languageId, snapshot) {
97-
const isVueFile = vueCompilerOptions.extensions.some(ext => fileId.endsWith(ext))
98-
|| (vueCompilerOptions.extensions.length && languageId === 'vue');
99-
const isVitePressFile = vueCompilerOptions.vitePressExtensions.some(ext => fileId.endsWith(ext))
100-
|| (vueCompilerOptions.vitePressExtensions.length && languageId === 'markdown');
101-
const isPetiteVueFile = vueCompilerOptions.petiteVueExtensions.some(ext => fileId.endsWith(ext))
102-
|| (vueCompilerOptions.petiteVueExtensions.length && languageId === 'html');
103-
if (isVueFile || isVitePressFile || isPetiteVueFile) {
108+
if (languageId === 'vue' || languageId === 'markdown' || languageId === 'html') {
104109
const fileName = getFileName(fileId);
105110
const projectVersion = getProjectVersion();
106111
if (projectVersion !== canonicalRootFileNamesVersion) {
@@ -122,9 +127,9 @@ export function createVueLanguagePlugin(
122127
languageId,
123128
snapshot,
124129
vueCompilerOptions,
125-
isPetiteVueFile
130+
languageId === 'html'
126131
? [petiteVueSfcPlugin, ...basePlugins]
127-
: isVitePressFile
132+
: languageId === 'markdown'
128133
? [vitePressSfcPlugin, ...basePlugins]
129134
: [vueSfcPlugin, ...basePlugins],
130135
ts,

packages/language-core/lib/virtualFile/computedFiles.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VirtualCode, buildMappings, resolveCommonLanguageId, toString } from '@volar/language-core';
1+
import { VirtualCode, buildMappings, toString } from '@volar/language-core';
22
import { computed } from 'computeds';
33
import type * as ts from 'typescript';
44
import type { Code, Sfc, SfcBlock, VueLanguagePlugin } from '../types';
@@ -57,7 +57,7 @@ export function computedFiles(
5757
if (!file.parentCodeId) {
5858
embeddedCodes.push({
5959
id: file.id,
60-
languageId: resolveCommonLanguageId(`/dummy.${file.lang}`),
60+
languageId: resolveCommonLanguageId(file.lang),
6161
linkedCodeMappings: file.linkedCodeMappings,
6262
snapshot,
6363
mappings,
@@ -71,7 +71,7 @@ export function computedFiles(
7171
parent.embeddedCodes ??= [];
7272
parent.embeddedCodes.push({
7373
id: file.id,
74-
languageId: resolveCommonLanguageId(`/dummy.${file.lang}`),
74+
languageId: resolveCommonLanguageId(file.lang),
7575
linkedCodeMappings: file.linkedCodeMappings,
7676
snapshot,
7777
mappings,
@@ -238,3 +238,19 @@ function fullDiffTextChangeRange(oldText: string, newText: string): ts.TextChang
238238
}
239239
}
240240
}
241+
242+
export function resolveCommonLanguageId(lang: string) {
243+
switch (lang) {
244+
case 'js': return 'javascript';
245+
case 'cjs': return 'javascript';
246+
case 'mjs': return 'javascript';
247+
case 'ts': return 'typescript';
248+
case 'cts': return 'typescript';
249+
case 'mts': return 'typescript';
250+
case 'jsx': return 'javascriptreact';
251+
case 'tsx': return 'typescriptreact';
252+
case 'pug': return 'jade';
253+
case 'md': return 'markdown';
254+
}
255+
return lang;
256+
}

packages/language-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"directory": "packages/language-core"
1313
},
1414
"dependencies": {
15-
"@volar/language-core": "2.2.0-alpha.10",
15+
"@volar/language-core": "2.2.0-alpha.12",
1616
"@vue/compiler-dom": "^3.4.0",
1717
"@vue/shared": "^3.4.0",
1818
"computeds": "^0.0.1",

packages/language-plugin-pug/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@vue/language-core": "2.0.14"
1717
},
1818
"dependencies": {
19-
"@volar/source-map": "2.2.0-alpha.10",
19+
"@volar/source-map": "2.2.0-alpha.12",
2020
"volar-service-pug": "0.0.40"
2121
}
2222
}

0 commit comments

Comments
 (0)