/
vue-sfc-styles.ts
58 lines (51 loc) · 1.13 KB
/
vue-sfc-styles.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as SourceMaps from '@volar/source-map';
import { EmbeddedFile, VueLanguagePlugin } from '../sourceFile';
export default function (): VueLanguagePlugin {
return {
getEmbeddedFilesCount(fileName, sfc) {
return sfc.styles.length;
},
getEmbeddedFile(fileName, sfc, i) {
const style = sfc.styles[i];
const file: EmbeddedFile = {
fileName: fileName + '.' + i + '.' + style.lang,
content: style.content,
capabilities: {
diagnostics: true,
foldingRanges: true,
formatting: true,
documentSymbol: true,
codeActions: true,
inlayHints: true,
},
isTsHostFile: false,
mappings: [],
};
file.mappings.push({
data: {
vueTag: style.tag,
vueTagIndex: i,
capabilities: {
basic: true,
references: true,
definitions: true,
diagnostic: true,
rename: true,
completion: true,
semanticTokens: true,
},
},
mode: SourceMaps.Mode.Offset,
sourceRange: {
start: 0,
end: style.content.length,
},
mappedRange: {
start: 0,
end: style.content.length,
},
});
return file;
},
};
}