@volar/language-server 1.3.0-alpha.3 → 1.4.0-alpha.0
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.
- package/out/browser/index.js +1 -1
- package/out/common/features/languageFeatures.d.ts +1 -0
- package/out/common/features/languageFeatures.js +61 -66
- package/out/common/project.d.ts +75 -85
- package/out/common/project.js +12 -11
- package/out/common/server.js +23 -49
- package/out/common/utils/registerFeatures.d.ts +2 -2
- package/out/common/utils/registerFeatures.js +27 -74
- package/out/common/workspace.d.ts +675 -747
- package/out/common/workspace.js +0 -4
- package/out/common/workspaces.d.ts +826 -913
- package/out/common/workspaces.js +12 -6
- package/out/node/index.js +1 -1
- package/out/types.d.ts +6 -12
- package/out/types.js +1 -1
- package/package.json +4 -5
package/out/common/server.js
CHANGED
|
@@ -9,6 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.startCommonLanguageServer = void 0;
|
|
12
|
+
const language_service_1 = require("@volar/language-service");
|
|
13
|
+
const l10n = require("@vscode/l10n");
|
|
12
14
|
const vscode = require("vscode-languageserver");
|
|
13
15
|
const vscode_uri_1 = require("vscode-uri");
|
|
14
16
|
const types_1 = require("../types");
|
|
@@ -16,8 +18,8 @@ const cancellationPipe_1 = require("./cancellationPipe");
|
|
|
16
18
|
const configurationHost_1 = require("./configurationHost");
|
|
17
19
|
const documents_1 = require("./documents");
|
|
18
20
|
const registerFeatures_1 = require("./utils/registerFeatures");
|
|
21
|
+
const serverConfig_1 = require("./utils/serverConfig");
|
|
19
22
|
const workspaces_1 = require("./workspaces");
|
|
20
|
-
const l10n = require("@vscode/l10n");
|
|
21
23
|
function startCommonLanguageServer(connection, getCtx) {
|
|
22
24
|
let initParams;
|
|
23
25
|
let options;
|
|
@@ -53,7 +55,22 @@ function startCommonLanguageServer(connection, getCtx) {
|
|
|
53
55
|
},
|
|
54
56
|
};
|
|
55
57
|
configurationHost = ((_c = initParams.capabilities.workspace) === null || _c === void 0 ? void 0 : _c.configuration) ? (0, configurationHost_1.createConfigurationHost)(initParams, connection) : undefined;
|
|
56
|
-
|
|
58
|
+
let lsPlugins = {};
|
|
59
|
+
const ts = options.typescript ? context.runtimeEnv.loadTypescript(options.typescript.tsdk) : undefined;
|
|
60
|
+
for (const root of roots) {
|
|
61
|
+
if (root.scheme === 'file') {
|
|
62
|
+
let config = (_d = (0, serverConfig_1.loadConfig)(root.path, options.configFilePath)) !== null && _d !== void 0 ? _d : {};
|
|
63
|
+
for (const plugin of plugins) {
|
|
64
|
+
if (plugin.resolveConfig) {
|
|
65
|
+
config = plugin.resolveConfig(config, { typescript: ts });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (config.plugins) {
|
|
69
|
+
lsPlugins = Object.assign(Object.assign({}, lsPlugins), config.plugins);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
(0, registerFeatures_1.setupCapabilities)(result.capabilities, options, plugins, getSemanticTokensLegend(), lsPlugins);
|
|
57
74
|
yield createLanguageServiceHost();
|
|
58
75
|
try {
|
|
59
76
|
// show version on LSP logs
|
|
@@ -64,9 +81,6 @@ function startCommonLanguageServer(connection, getCtx) {
|
|
|
64
81
|
};
|
|
65
82
|
}
|
|
66
83
|
catch (_e) { }
|
|
67
|
-
for (const plugin of plugins) {
|
|
68
|
-
(_d = plugin.onInitialize) === null || _d === void 0 ? void 0 : _d.call(plugin, result, context.runtimeEnv);
|
|
69
|
-
}
|
|
70
84
|
return result;
|
|
71
85
|
}));
|
|
72
86
|
connection.onInitialized(() => {
|
|
@@ -86,7 +100,7 @@ function startCommonLanguageServer(connection, getCtx) {
|
|
|
86
100
|
if (options.serverMode !== types_1.ServerMode.Syntactic
|
|
87
101
|
&& !options.disableFileWatcher
|
|
88
102
|
&& ((_c = (_b = initParams.capabilities.workspace) === null || _b === void 0 ? void 0 : _b.didChangeWatchedFiles) === null || _c === void 0 ? void 0 : _c.dynamicRegistration)) {
|
|
89
|
-
const exts = plugins.map(plugin =>
|
|
103
|
+
const exts = plugins.map(plugin => plugin.watchFileExtensions).flat();
|
|
90
104
|
if (exts.length) {
|
|
91
105
|
connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
|
|
92
106
|
watchers: [
|
|
@@ -145,53 +159,13 @@ function startCommonLanguageServer(connection, getCtx) {
|
|
|
145
159
|
}
|
|
146
160
|
function getSemanticTokensLegend() {
|
|
147
161
|
if (!options.semanticTokensLegend) {
|
|
148
|
-
return standardSemanticTokensLegend;
|
|
162
|
+
return language_service_1.standardSemanticTokensLegend;
|
|
149
163
|
}
|
|
150
164
|
return {
|
|
151
|
-
tokenTypes: [...standardSemanticTokensLegend.tokenTypes, ...options.semanticTokensLegend.tokenTypes],
|
|
152
|
-
tokenModifiers: [...standardSemanticTokensLegend.tokenModifiers, ...options.semanticTokensLegend.tokenModifiers],
|
|
165
|
+
tokenTypes: [...language_service_1.standardSemanticTokensLegend.tokenTypes, ...options.semanticTokensLegend.tokenTypes],
|
|
166
|
+
tokenModifiers: [...language_service_1.standardSemanticTokensLegend.tokenModifiers, ...options.semanticTokensLegend.tokenModifiers],
|
|
153
167
|
};
|
|
154
168
|
}
|
|
155
169
|
}
|
|
156
170
|
exports.startCommonLanguageServer = startCommonLanguageServer;
|
|
157
|
-
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
|
|
158
|
-
const standardSemanticTokensLegend = {
|
|
159
|
-
tokenTypes: [
|
|
160
|
-
'namespace',
|
|
161
|
-
'class',
|
|
162
|
-
'enum',
|
|
163
|
-
'interface',
|
|
164
|
-
'struct',
|
|
165
|
-
'typeParameter',
|
|
166
|
-
'type',
|
|
167
|
-
'parameter',
|
|
168
|
-
'variable',
|
|
169
|
-
'property',
|
|
170
|
-
'enumMember',
|
|
171
|
-
'decorator',
|
|
172
|
-
'event',
|
|
173
|
-
'function',
|
|
174
|
-
'method',
|
|
175
|
-
'macro',
|
|
176
|
-
'label',
|
|
177
|
-
'comment',
|
|
178
|
-
'string',
|
|
179
|
-
'keyword',
|
|
180
|
-
'number',
|
|
181
|
-
'regexp',
|
|
182
|
-
'operator',
|
|
183
|
-
],
|
|
184
|
-
tokenModifiers: [
|
|
185
|
-
'declaration',
|
|
186
|
-
'definition',
|
|
187
|
-
'readonly',
|
|
188
|
-
'static',
|
|
189
|
-
'deprecated',
|
|
190
|
-
'abstract',
|
|
191
|
-
'async',
|
|
192
|
-
'modification',
|
|
193
|
-
'documentation',
|
|
194
|
-
'defaultLibrary',
|
|
195
|
-
],
|
|
196
|
-
};
|
|
197
171
|
//# sourceMappingURL=server.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { LanguageServerPlugin, LanguageServerInitializationOptions } from '../../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver';
|
|
3
|
-
import {
|
|
4
|
-
export declare function setupCapabilities(
|
|
3
|
+
import { Config } from '@volar/language-service';
|
|
4
|
+
export declare function setupCapabilities(server: vscode.ServerCapabilities, initOptions: LanguageServerInitializationOptions, plugins: ReturnType<LanguageServerPlugin>[], semanticTokensLegend: vscode.SemanticTokensLegend, lsPlugins: NonNullable<Config['plugins']>): void;
|
|
@@ -3,99 +3,62 @@ exports.setupCapabilities = void 0;
|
|
|
3
3
|
const embedded = require("@volar/language-service");
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const vscode = require("vscode-languageserver");
|
|
6
|
-
function setupCapabilities(
|
|
7
|
-
var _a, _b, _c
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
function setupCapabilities(server, initOptions, plugins, semanticTokensLegend, lsPlugins) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const lsPluginInstances = Object.values(lsPlugins)
|
|
9
|
+
.map(plugin => typeof plugin === 'function' ? plugin() : plugin)
|
|
10
|
+
.filter((plugin) => !!plugin);
|
|
11
|
+
if (initOptions.serverMode === types_1.ServerMode.Semantic || initOptions.serverMode === types_1.ServerMode.Syntactic) {
|
|
10
12
|
server.selectionRangeProvider = true;
|
|
11
|
-
}
|
|
12
|
-
if (!initOptions.respectClientCapabilities || ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.foldingRange)) {
|
|
13
13
|
server.foldingRangeProvider = true;
|
|
14
|
-
}
|
|
15
|
-
if (!initOptions.respectClientCapabilities || ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.linkedEditingRange)) {
|
|
16
14
|
server.linkedEditingRangeProvider = true;
|
|
17
|
-
}
|
|
18
|
-
if (!initOptions.respectClientCapabilities || ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.colorProvider)) {
|
|
19
15
|
server.colorProvider = true;
|
|
20
|
-
}
|
|
21
|
-
if (!initOptions.respectClientCapabilities || ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.documentSymbol)) {
|
|
22
16
|
server.documentSymbolProvider = true;
|
|
23
|
-
}
|
|
24
|
-
if (!initOptions.respectClientCapabilities || ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.formatting)) {
|
|
25
17
|
server.documentFormattingProvider = true;
|
|
26
|
-
}
|
|
27
|
-
if (!initOptions.respectClientCapabilities || ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rangeFormatting)) {
|
|
28
18
|
server.documentRangeFormattingProvider = true;
|
|
19
|
+
const characters = [...new Set(lsPluginInstances.map(plugin => { var _a; return (_a = plugin.autoFormatTriggerCharacters) !== null && _a !== void 0 ? _a : []; }).flat())];
|
|
20
|
+
if (characters.length) {
|
|
21
|
+
server.documentOnTypeFormattingProvider = {
|
|
22
|
+
firstTriggerCharacter: characters[0],
|
|
23
|
+
moreTriggerCharacter: characters.slice(1),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
29
26
|
}
|
|
30
|
-
if (
|
|
31
|
-
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
|
|
32
|
-
server.documentOnTypeFormattingProvider = {
|
|
33
|
-
firstTriggerCharacter: ';',
|
|
34
|
-
moreTriggerCharacter: ['}', '\n'],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
// Semantic
|
|
38
|
-
if (!initOptions.respectClientCapabilities || ((_j = params.textDocument) === null || _j === void 0 ? void 0 : _j.references)) {
|
|
27
|
+
if (initOptions.serverMode === types_1.ServerMode.Semantic || initOptions.serverMode === types_1.ServerMode.PartialSemantic) {
|
|
39
28
|
server.referencesProvider = true;
|
|
40
|
-
}
|
|
41
|
-
if (!initOptions.respectClientCapabilities || ((_k = params.textDocument) === null || _k === void 0 ? void 0 : _k.implementation)) {
|
|
42
29
|
server.implementationProvider = true;
|
|
43
|
-
}
|
|
44
|
-
if (!initOptions.respectClientCapabilities || ((_l = params.textDocument) === null || _l === void 0 ? void 0 : _l.definition)) {
|
|
45
30
|
server.definitionProvider = true;
|
|
46
|
-
}
|
|
47
|
-
if (!initOptions.respectClientCapabilities || ((_m = params.textDocument) === null || _m === void 0 ? void 0 : _m.typeDefinition)) {
|
|
48
31
|
server.typeDefinitionProvider = true;
|
|
49
|
-
}
|
|
50
|
-
if (!initOptions.respectClientCapabilities || ((_o = params.textDocument) === null || _o === void 0 ? void 0 : _o.callHierarchy)) {
|
|
51
32
|
server.callHierarchyProvider = true;
|
|
52
|
-
}
|
|
53
|
-
if (!initOptions.respectClientCapabilities || ((_p = params.textDocument) === null || _p === void 0 ? void 0 : _p.hover)) {
|
|
54
33
|
server.hoverProvider = true;
|
|
55
|
-
}
|
|
56
|
-
if (!initOptions.respectClientCapabilities || ((_q = params.textDocument) === null || _q === void 0 ? void 0 : _q.rename)) {
|
|
57
34
|
server.renameProvider = {
|
|
58
35
|
prepareProvider: true,
|
|
59
36
|
};
|
|
60
|
-
}
|
|
61
|
-
if (!initOptions.respectClientCapabilities || ((_r = params.textDocument) === null || _r === void 0 ? void 0 : _r.signatureHelp)) {
|
|
62
37
|
server.signatureHelpProvider = {
|
|
63
|
-
triggerCharacters: [
|
|
64
|
-
retriggerCharacters: [
|
|
38
|
+
triggerCharacters: [...new Set(lsPluginInstances.map(plugin => { var _a; return (_a = plugin.signatureHelpTriggerCharacters) !== null && _a !== void 0 ? _a : []; }).flat())],
|
|
39
|
+
retriggerCharacters: [...new Set(lsPluginInstances.map(plugin => { var _a; return (_a = plugin.signatureHelpRetriggerCharacters) !== null && _a !== void 0 ? _a : []; }).flat())],
|
|
65
40
|
};
|
|
66
|
-
}
|
|
67
|
-
if (!initOptions.respectClientCapabilities || ((_s = params.textDocument) === null || _s === void 0 ? void 0 : _s.completion)) {
|
|
68
41
|
server.completionProvider = {
|
|
69
|
-
triggerCharacters:
|
|
42
|
+
triggerCharacters: [...new Set(lsPluginInstances.map(plugin => { var _a; return (_a = plugin.triggerCharacters) !== null && _a !== void 0 ? _a : []; }).flat())],
|
|
70
43
|
resolveProvider: true,
|
|
71
44
|
};
|
|
72
45
|
if (initOptions.ignoreTriggerCharacters) {
|
|
73
|
-
server.completionProvider.triggerCharacters = (
|
|
46
|
+
server.completionProvider.triggerCharacters = (_a = server.completionProvider.triggerCharacters) === null || _a === void 0 ? void 0 : _a.filter(c => !initOptions.ignoreTriggerCharacters.includes(c));
|
|
74
47
|
}
|
|
75
|
-
}
|
|
76
|
-
if (!initOptions.respectClientCapabilities || ((_u = params.textDocument) === null || _u === void 0 ? void 0 : _u.documentHighlight)) {
|
|
77
48
|
server.documentHighlightProvider = true;
|
|
78
|
-
}
|
|
79
|
-
if (!initOptions.respectClientCapabilities || ((_v = params.textDocument) === null || _v === void 0 ? void 0 : _v.documentLink)) {
|
|
80
49
|
server.documentLinkProvider = {
|
|
81
50
|
resolveProvider: false, // TODO
|
|
82
51
|
};
|
|
83
|
-
}
|
|
84
|
-
if (!initOptions.respectClientCapabilities || ((_w = params.textDocument) === null || _w === void 0 ? void 0 : _w.codeLens)) {
|
|
85
52
|
server.codeLensProvider = {
|
|
86
53
|
resolveProvider: true,
|
|
87
54
|
};
|
|
88
|
-
(
|
|
55
|
+
(_b = server.executeCommandProvider) !== null && _b !== void 0 ? _b : (server.executeCommandProvider = { commands: [] });
|
|
89
56
|
server.executeCommandProvider.commands.push(embedded.showReferencesCommand);
|
|
90
|
-
}
|
|
91
|
-
if (!initOptions.respectClientCapabilities || ((_y = params.textDocument) === null || _y === void 0 ? void 0 : _y.semanticTokens)) {
|
|
92
57
|
server.semanticTokensProvider = {
|
|
93
58
|
range: true,
|
|
94
59
|
full: false,
|
|
95
60
|
legend: semanticTokensLegend,
|
|
96
61
|
};
|
|
97
|
-
}
|
|
98
|
-
if (!initOptions.respectClientCapabilities || ((_z = params.textDocument) === null || _z === void 0 ? void 0 : _z.codeAction)) {
|
|
99
62
|
server.codeActionProvider = {
|
|
100
63
|
codeActionKinds: [
|
|
101
64
|
vscode.CodeActionKind.Empty,
|
|
@@ -110,23 +73,8 @@ function setupCapabilities(params, server, initOptions, plugins, semanticTokensL
|
|
|
110
73
|
],
|
|
111
74
|
resolveProvider: true,
|
|
112
75
|
};
|
|
113
|
-
}
|
|
114
|
-
if (!initOptions.respectClientCapabilities || ((_0 = params.textDocument) === null || _0 === void 0 ? void 0 : _0.inlayHint)) {
|
|
115
76
|
server.inlayHintProvider = true;
|
|
116
|
-
|
|
117
|
-
if ((!initOptions.respectClientCapabilities || ((_1 = params.textDocument) === null || _1 === void 0 ? void 0 : _1.diagnostic)) && ((_2 = initOptions.diagnosticModel) !== null && _2 !== void 0 ? _2 : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
|
|
118
|
-
const selector = plugins.map(plugin => { var _a; return (_a = plugin.diagnosticDocumentSelector) !== null && _a !== void 0 ? _a : []; }).flat();
|
|
119
|
-
if (selector) {
|
|
120
|
-
server.diagnosticProvider = {
|
|
121
|
-
documentSelector: selector,
|
|
122
|
-
interFileDependencies: true,
|
|
123
|
-
workspaceDiagnostics: false,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// cross file features
|
|
128
|
-
if (!initOptions.respectClientCapabilities || ((_3 = params.workspace) === null || _3 === void 0 ? void 0 : _3.fileOperations)) {
|
|
129
|
-
const exts = plugins.map(plugin => plugin.extensions.fileRenameOperationFilter).flat();
|
|
77
|
+
const exts = plugins.map(plugin => plugin.watchFileExtensions).flat();
|
|
130
78
|
if (exts.length) {
|
|
131
79
|
server.workspace = {
|
|
132
80
|
fileOperations: {
|
|
@@ -142,10 +90,15 @@ function setupCapabilities(params, server, initOptions, plugins, semanticTokensL
|
|
|
142
90
|
}
|
|
143
91
|
};
|
|
144
92
|
}
|
|
145
|
-
}
|
|
146
|
-
if (!initOptions.respectClientCapabilities || ((_4 = params.workspace) === null || _4 === void 0 ? void 0 : _4.symbol)) {
|
|
147
93
|
server.workspaceSymbolProvider = true;
|
|
148
94
|
}
|
|
95
|
+
// diagnostics are shunted in the api
|
|
96
|
+
if (((_c = initOptions.diagnosticModel) !== null && _c !== void 0 ? _c : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
|
|
97
|
+
server.diagnosticProvider = {
|
|
98
|
+
interFileDependencies: true,
|
|
99
|
+
workspaceDiagnostics: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
149
102
|
}
|
|
150
103
|
exports.setupCapabilities = setupCapabilities;
|
|
151
104
|
//# sourceMappingURL=registerFeatures.js.map
|