Skip to content

Commit 11a8e5c

Browse files
authored
refactor: sync with language-tools v2.2.4 (#591)
1 parent 6e74d49 commit 11a8e5c

File tree

5 files changed

+74
-93
lines changed

5 files changed

+74
-93
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
"@types/node": "^22.13.1",
166166
"@vitest/coverage-v8": "^3.0.5",
167167
"@vitest/ui": "^3.0.5",
168-
"@volar/vue-language-core": "^1.6.5",
168+
"@vue/language-core": "^2.2.4",
169169
"@vue/test-utils": "^2.4.6",
170170
"chalk": "^5.4.1",
171171
"conventional-changelog-cli": "^5.0.0",

playground/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"vueCompilerOptions": {
3737
"plugins": [
38-
"../volar"
38+
"../volar/index.cjs"
3939
]
4040
},
4141
"references": [

pnpm-lock.yaml

+29-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

volar/index.cjs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// @ts-check
2+
3+
/**
4+
* @type {import('@vue/language-core').VueLanguagePlugin}
5+
*/
6+
const plugin = () => {
7+
return {
8+
version: 2.1,
9+
getEmbeddedCodes(fileName, sfc) {
10+
const names = [];
11+
for (let i = 0; i < sfc.customBlocks.length; i++) {
12+
const block = sfc.customBlocks[i]
13+
if (block.type === 'route') {
14+
const lang = block.lang === 'txt' ? 'json' : block.lang
15+
names.push({ id: `route_${i}`, lang })
16+
}
17+
}
18+
return names
19+
},
20+
resolveEmbeddedCode(fileName, sfc, embeddedCode) {
21+
const match = embeddedCode.id.match(/^route_(\d+)$/)
22+
if (match) {
23+
const index = parseInt(match[1])
24+
const block = sfc.customBlocks[index]
25+
embeddedCode.content.push([
26+
block.content,
27+
block.name,
28+
0,
29+
{
30+
verification: true,
31+
completion: true,
32+
semantic: true,
33+
navigation: true,
34+
structure: true,
35+
format: true,
36+
},
37+
])
38+
}
39+
},
40+
}
41+
}
42+
43+
module.exports = plugin

volar/index.js

-46
This file was deleted.

0 commit comments

Comments
 (0)