@vue/language-service 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/index.d.ts +7 -0
  2. package/index.js +64 -0
  3. package/lib/ideFeatures/nameCasing.d.ts +13 -0
  4. package/lib/ideFeatures/nameCasing.js +211 -0
  5. package/lib/plugins/css.d.ts +2 -0
  6. package/lib/plugins/css.js +27 -0
  7. package/lib/plugins/data.d.ts +4 -0
  8. package/lib/plugins/data.js +91 -0
  9. package/lib/plugins/vue-autoinsert-dotvalue.d.ts +10 -0
  10. package/lib/plugins/vue-autoinsert-dotvalue.js +177 -0
  11. package/lib/plugins/vue-autoinsert-parentheses.d.ts +2 -0
  12. package/lib/plugins/vue-autoinsert-parentheses.js +60 -0
  13. package/lib/plugins/vue-autoinsert-space.d.ts +2 -0
  14. package/lib/plugins/vue-autoinsert-space.js +34 -0
  15. package/lib/plugins/vue-codelens-references.d.ts +2 -0
  16. package/lib/plugins/vue-codelens-references.js +38 -0
  17. package/lib/plugins/vue-directive-comments.d.ts +2 -0
  18. package/lib/plugins/vue-directive-comments.js +61 -0
  19. package/lib/plugins/vue-document-drop.d.ts +2 -0
  20. package/lib/plugins/vue-document-drop.js +81 -0
  21. package/lib/plugins/vue-extract-file.d.ts +8 -0
  22. package/lib/plugins/vue-extract-file.js +258 -0
  23. package/lib/plugins/vue-sfc.d.ts +7 -0
  24. package/lib/plugins/vue-sfc.js +163 -0
  25. package/lib/plugins/vue-template.d.ts +3 -0
  26. package/lib/plugins/vue-template.js +594 -0
  27. package/lib/plugins/vue-toggle-v-bind-codeaction.d.ts +2 -0
  28. package/lib/plugins/vue-toggle-v-bind-codeaction.js +126 -0
  29. package/lib/plugins/vue-twoslash-queries.d.ts +2 -0
  30. package/lib/plugins/vue-twoslash-queries.js +50 -0
  31. package/lib/plugins/vue-visualize-hidden-callback-param.d.ts +2 -0
  32. package/lib/plugins/vue-visualize-hidden-callback-param.js +45 -0
  33. package/lib/types.d.ts +10 -0
  34. package/lib/types.js +31 -0
  35. package/package.json +6 -6
  36. package/scripts/update-html-data.js +426 -0
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = void 0;
4
+ const vue = require("@vue/language-core");
5
+ const volar_service_html_1 = require("volar-service-html");
6
+ const html = require("vscode-html-languageservice");
7
+ const data_1 = require("./data");
8
+ let sfcDataProvider;
9
+ function create() {
10
+ return {
11
+ name: 'vue-sfc',
12
+ create(context) {
13
+ const htmlPlugin = (0, volar_service_html_1.create)({
14
+ documentSelector: ['vue'],
15
+ useCustomDataProviders: false,
16
+ }).create(context);
17
+ const htmlLanguageService = htmlPlugin.provide['html/languageService']();
18
+ sfcDataProvider ??= html.newHTMLDataProvider('vue', (0, data_1.loadLanguageBlocks)(context.env.locale ?? 'en'));
19
+ htmlLanguageService.setDataProviders(false, [sfcDataProvider]);
20
+ return {
21
+ ...htmlPlugin,
22
+ provide: {
23
+ 'vue/vueFile': document => {
24
+ return worker(document, (vueFile) => {
25
+ return vueFile;
26
+ });
27
+ },
28
+ },
29
+ async resolveEmbeddedCodeFormattingOptions(code, options) {
30
+ const sourceFile = context.language.files.getByVirtualCode(code);
31
+ if (sourceFile.generated?.code instanceof vue.VueGeneratedCode) {
32
+ if (code.id === 'scriptFormat' || code.id === 'scriptSetupFormat') {
33
+ if (await context.env.getConfiguration?.('vue.format.script.initialIndent') ?? false) {
34
+ options.initialIndentLevel++;
35
+ }
36
+ }
37
+ else if (code.id.startsWith('style_')) {
38
+ if (await context.env.getConfiguration?.('vue.format.style.initialIndent') ?? false) {
39
+ options.initialIndentLevel++;
40
+ }
41
+ }
42
+ else if (code.id === 'template') {
43
+ if (await context.env.getConfiguration?.('vue.format.template.initialIndent') ?? true) {
44
+ options.initialIndentLevel++;
45
+ }
46
+ }
47
+ }
48
+ return options;
49
+ },
50
+ provideDocumentLinks: undefined,
51
+ provideDocumentSymbols(document) {
52
+ return worker(document, (vueSourceFile) => {
53
+ const result = [];
54
+ const descriptor = vueSourceFile.sfc;
55
+ if (descriptor.template) {
56
+ result.push({
57
+ name: 'template',
58
+ kind: 2,
59
+ range: {
60
+ start: document.positionAt(descriptor.template.start),
61
+ end: document.positionAt(descriptor.template.end),
62
+ },
63
+ selectionRange: {
64
+ start: document.positionAt(descriptor.template.start),
65
+ end: document.positionAt(descriptor.template.startTagEnd),
66
+ },
67
+ });
68
+ }
69
+ if (descriptor.script) {
70
+ result.push({
71
+ name: 'script',
72
+ kind: 2,
73
+ range: {
74
+ start: document.positionAt(descriptor.script.start),
75
+ end: document.positionAt(descriptor.script.end),
76
+ },
77
+ selectionRange: {
78
+ start: document.positionAt(descriptor.script.start),
79
+ end: document.positionAt(descriptor.script.startTagEnd),
80
+ },
81
+ });
82
+ }
83
+ if (descriptor.scriptSetup) {
84
+ result.push({
85
+ name: 'script setup',
86
+ kind: 2,
87
+ range: {
88
+ start: document.positionAt(descriptor.scriptSetup.start),
89
+ end: document.positionAt(descriptor.scriptSetup.end),
90
+ },
91
+ selectionRange: {
92
+ start: document.positionAt(descriptor.scriptSetup.start),
93
+ end: document.positionAt(descriptor.scriptSetup.startTagEnd),
94
+ },
95
+ });
96
+ }
97
+ for (const style of descriptor.styles) {
98
+ let name = 'style';
99
+ if (style.scoped)
100
+ name += ' scoped';
101
+ if (style.module)
102
+ name += ' module';
103
+ result.push({
104
+ name,
105
+ kind: 2,
106
+ range: {
107
+ start: document.positionAt(style.start),
108
+ end: document.positionAt(style.end),
109
+ },
110
+ selectionRange: {
111
+ start: document.positionAt(style.start),
112
+ end: document.positionAt(style.startTagEnd),
113
+ },
114
+ });
115
+ }
116
+ for (const customBlock of descriptor.customBlocks) {
117
+ result.push({
118
+ name: `${customBlock.type}`,
119
+ kind: 2,
120
+ range: {
121
+ start: document.positionAt(customBlock.start),
122
+ end: document.positionAt(customBlock.end),
123
+ },
124
+ selectionRange: {
125
+ start: document.positionAt(customBlock.start),
126
+ end: document.positionAt(customBlock.startTagEnd),
127
+ },
128
+ });
129
+ }
130
+ return result;
131
+ });
132
+ },
133
+ provideDocumentFormattingEdits(document, range, options) {
134
+ return worker(document, async (vueCode) => {
135
+ const formatSettings = await context.env.getConfiguration?.('html.format') ?? {};
136
+ const blockTypes = ['template', 'script', 'style'];
137
+ for (const customBlock of vueCode.sfc.customBlocks) {
138
+ blockTypes.push(customBlock.type);
139
+ }
140
+ return htmlLanguageService.format(document, range, {
141
+ ...options,
142
+ ...formatSettings,
143
+ unformatted: '',
144
+ contentUnformatted: blockTypes.join(','),
145
+ extraLiners: blockTypes.join(','),
146
+ endWithNewline: options.insertFinalNewline ? true
147
+ : options.trimFinalNewlines ? false
148
+ : document.getText().endsWith('\n'),
149
+ });
150
+ });
151
+ },
152
+ };
153
+ function worker(document, callback) {
154
+ const [vueFile] = context.documents.getVirtualCodeByUri(document.uri);
155
+ if (vueFile instanceof vue.VueGeneratedCode) {
156
+ return callback(vueFile);
157
+ }
158
+ }
159
+ },
160
+ };
161
+ }
162
+ exports.create = create;
163
+ //# sourceMappingURL=vue-sfc.js.map
@@ -0,0 +1,3 @@
1
+ import type { ServiceEnvironment } from '@volar/language-service';
2
+ import { ServicePlugin, VueCompilerOptions } from '../types';
3
+ export declare function create(mode: 'html' | 'pug', ts: typeof import('typescript'), getVueOptions: (env: ServiceEnvironment) => VueCompilerOptions): ServicePlugin;