@volar/language-server 1.0.0-beta.1 → 1.0.0-beta.3

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.
@@ -1,4 +1,3 @@
1
1
  import * as vscode from 'vscode-languageserver';
2
2
  import type { Workspaces } from '../utils/workspaces';
3
- import { LanguageServerPlugin } from '../types';
4
- export declare function register(connection: vscode.Connection, projects: Workspaces, plugins: ReturnType<LanguageServerPlugin>[]): void;
3
+ export declare function register(connection: vscode.Connection, projects: Workspaces): void;
@@ -10,24 +10,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
12
  const shared = require("@volar/shared");
13
- const path = require("upath");
13
+ const path = require("typesafe-path");
14
14
  const vscode = require("vscode-languageserver");
15
- const requests_1 = require("../requests");
16
- function register(connection, projects, plugins) {
17
- var _a, _b;
18
- connection.onRequest(requests_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
19
- var _c;
20
- return (_c = (yield projects.getProject(params.uri))) === null || _c === void 0 ? void 0 : _c.tsconfig;
15
+ const protocol_1 = require("../protocol");
16
+ function register(connection, projects) {
17
+ connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
+ return (_a = (yield projects.getProject(params.uri))) === null || _a === void 0 ? void 0 : _a.tsconfig;
21
20
  }));
22
- connection.onNotification(requests_1.ReloadProjectNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
21
+ connection.onNotification(protocol_1.ReloadProjectNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
23
22
  projects.reloadProject();
24
23
  }));
25
- connection.onNotification(requests_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
26
- var _d;
24
+ connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
25
+ var _b;
27
26
  const fs = yield Promise.resolve().then(() => require('fs'));
28
27
  const project = yield projects.getProject(params.uri);
29
28
  if (project) {
30
- const ls = (_d = (yield project.project)) === null || _d === void 0 ? void 0 : _d.getLanguageServiceDontCreate();
29
+ const ls = (_b = (yield project.project)) === null || _b === void 0 ? void 0 : _b.getLanguageServiceDontCreate();
31
30
  if (ls) {
32
31
  const sourceFiles = new Set(ls.context.host.getScriptFileNames());
33
32
  for (const virtualFile of ls.context.core.typescriptLanguageServiceHost.getScriptFileNames()) {
@@ -41,15 +40,15 @@ function register(connection, projects, plugins) {
41
40
  }
42
41
  }
43
42
  }));
44
- connection.onNotification(requests_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
45
- var _e;
43
+ connection.onNotification(protocol_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
44
+ var _c;
46
45
  let errors = 0;
47
46
  let warnings = 0;
48
47
  const progress = yield connection.window.createWorkDoneProgress();
49
48
  progress.begin('Verify', 0, '', true);
50
49
  const project = yield projects.getProject(params.uri);
51
50
  if (project) {
52
- const ls = (_e = (yield project.project)) === null || _e === void 0 ? void 0 : _e.getLanguageServiceDontCreate();
51
+ const ls = (_c = (yield project.project)) === null || _c === void 0 ? void 0 : _c.getLanguageServiceDontCreate();
53
52
  if (ls) {
54
53
  const allVueDocuments = ls.context.documents.getAll();
55
54
  let i = 0;
@@ -58,7 +57,7 @@ function register(connection, projects, plugins) {
58
57
  if (progress.token.isCancellationRequested) {
59
58
  continue;
60
59
  }
61
- let _result = yield ls.doValidation(vueFile.uri);
60
+ let _result = yield ls.doValidation(vueFile.uri, progress.token);
62
61
  connection.sendDiagnostics({ uri: vueFile.uri, diagnostics: _result });
63
62
  errors += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Error).length;
64
63
  warnings += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Warning).length;
@@ -68,16 +67,6 @@ function register(connection, projects, plugins) {
68
67
  progress.done();
69
68
  connection.window.showInformationMessage(`Verification complete. Found ${errors} errors and ${warnings} warnings.`);
70
69
  }));
71
- for (const plugin of plugins) {
72
- (_b = (_a = plugin.languageService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, connection, getLanguageService);
73
- }
74
- function getLanguageService(uri) {
75
- var _a;
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const project = (_a = (yield projects.getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
78
- return project === null || project === void 0 ? void 0 : project.getLanguageService();
79
- });
80
- }
81
70
  }
82
71
  exports.register = register;
83
72
  //# sourceMappingURL=customFeatures.js.map
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
- const requests_1 = require("../requests");
12
+ const protocol_1 = require("../protocol");
13
13
  function register(connection, documents, documentServiceHost) {
14
14
  connection.onDocumentFormatting(params => {
15
15
  return worker(params.textDocument.uri, document => {
@@ -56,7 +56,7 @@ function register(connection, documents, documentServiceHost) {
56
56
  return documentServiceHost.get(document.uri).getColorPresentations(document, params.color, params.range);
57
57
  });
58
58
  });
59
- connection.onRequest(requests_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
59
+ connection.onRequest(protocol_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
60
60
  return worker(params.textDocument.uri, document => {
61
61
  return documentServiceHost.get(document.uri).doAutoInsert(document, params.position, params.options);
62
62
  });
@@ -1,4 +1,4 @@
1
1
  import * as vscode from 'vscode-languageserver';
2
- import { ServerInitializationOptions } from '../types';
2
+ import { CancellactionTokenHost } from '../utils/cancellationPipe';
3
3
  import type { Workspaces } from '../utils/workspaces';
4
- export declare function register(connection: vscode.Connection, projects: Workspaces, features: NonNullable<ServerInitializationOptions['languageFeatures']>, initParams: vscode.InitializeParams): void;
4
+ export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellactionTokenHost): void;
@@ -11,8 +11,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
12
  const embedded = require("@volar/language-service");
13
13
  const vscode = require("vscode-languageserver");
14
- const requests_1 = require("../requests");
15
- function register(connection, projects, features, initParams) {
14
+ const protocol_1 = require("../protocol");
15
+ const shared = require("@volar/shared");
16
+ function register(connection, projects, initParams, cancelHost) {
16
17
  let lastCompleteUri;
17
18
  let lastCompleteLs;
18
19
  let lastCodeLensLs;
@@ -33,11 +34,7 @@ function register(connection, projects, features, initParams) {
33
34
  }));
34
35
  connection.onCompletionResolve((item) => __awaiter(this, void 0, void 0, function* () {
35
36
  if (lastCompleteUri && lastCompleteLs) {
36
- const activeSel = typeof features.completion === 'object' && features.completion.getDocumentSelectionRequest
37
- ? yield connection.sendRequest(requests_1.GetEditorSelectionRequest.type)
38
- : undefined;
39
- const newPosition = (activeSel === null || activeSel === void 0 ? void 0 : activeSel.textDocument.uri.toLowerCase()) === lastCompleteUri.toLowerCase() ? activeSel.position : undefined;
40
- item = yield lastCompleteLs.doCompletionResolve(item, newPosition);
37
+ item = yield lastCompleteLs.doCompletionResolve(item);
41
38
  fixTextEdit(item);
42
39
  }
43
40
  return item;
@@ -83,7 +80,7 @@ function register(connection, projects, features, initParams) {
83
80
  token,
84
81
  workDoneProgress,
85
82
  applyEdit: (paramOrEdit) => connection.workspace.applyEdit(paramOrEdit),
86
- showReferences: (params) => connection.sendNotification(requests_1.ShowReferencesNotification.type, params),
83
+ showReferences: (params) => connection.sendNotification(protocol_1.ShowReferencesNotification.type, params),
87
84
  });
88
85
  });
89
86
  }
@@ -116,7 +113,7 @@ function register(connection, projects, features, initParams) {
116
113
  return vueLs.findReferences(params.textDocument.uri, params.position);
117
114
  });
118
115
  }));
119
- connection.onRequest(requests_1.FindFileReferenceRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
116
+ connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
120
117
  return worker(params.textDocument.uri, vueLs => {
121
118
  return vueLs.findFileReferences(params.textDocument.uri);
122
119
  });
@@ -178,6 +175,9 @@ function register(connection, projects, features, initParams) {
178
175
  }));
179
176
  connection.languages.semanticTokens.on((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
180
177
  var _j;
178
+ yield shared.sleep(200);
179
+ if (token.isCancellationRequested)
180
+ return buildTokens([]);
181
181
  return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
182
182
  var _k;
183
183
  const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
@@ -186,15 +186,19 @@ function register(connection, projects, features, initParams) {
186
186
  }));
187
187
  connection.languages.semanticTokens.onRange((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
188
188
  var _l;
189
+ yield shared.sleep(200);
190
+ if (token.isCancellationRequested)
191
+ return buildTokens([]);
189
192
  return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
190
193
  var _m;
191
194
  const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
192
195
  return buildTokens(result);
193
196
  }))) !== null && _l !== void 0 ? _l : buildTokens([]);
194
197
  }));
195
- connection.languages.diagnostics.on((params, cancellationToken, workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
198
+ connection.languages.diagnostics.on((params, token, workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
199
+ token = cancelHost.createCancellactionToken(token);
196
200
  const result = yield worker(params.textDocument.uri, vueLs => {
197
- return vueLs.doValidation(params.textDocument.uri, errors => {
201
+ return vueLs.doValidation(params.textDocument.uri, token, errors => {
198
202
  // resultProgressReporter is undefined in vscode
199
203
  resultProgressReporter === null || resultProgressReporter === void 0 ? void 0 : resultProgressReporter.report({
200
204
  relatedDocuments: {
@@ -204,7 +208,7 @@ function register(connection, projects, features, initParams) {
204
208
  },
205
209
  },
206
210
  });
207
- }, cancellationToken);
211
+ });
208
212
  });
209
213
  return {
210
214
  kind: vscode.DocumentDiagnosticReportKind.Full,
@@ -212,9 +216,9 @@ function register(connection, projects, features, initParams) {
212
216
  };
213
217
  }));
214
218
  connection.languages.inlayHint.on((params) => __awaiter(this, void 0, void 0, function* () {
215
- return worker(params.textDocument.uri, vueLs => {
219
+ return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
216
220
  return vueLs.getInlayHints(params.textDocument.uri, params.range);
217
- });
221
+ }));
218
222
  }));
219
223
  // TODO: connection.languages.inlayHint.resolve
220
224
  connection.workspace.onWillRenameFiles((params) => __awaiter(this, void 0, void 0, function* () {
@@ -232,7 +236,7 @@ function register(connection, projects, features, initParams) {
232
236
  return (_a = vueLs.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
233
237
  })) !== null && _o !== void 0 ? _o : null;
234
238
  }));
235
- connection.onRequest(requests_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
239
+ connection.onRequest(protocol_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
236
240
  return worker(params.textDocument.uri, vueLs => {
237
241
  return vueLs.doAutoInsert(params.textDocument.uri, params.position, params.options);
238
242
  });
@@ -241,7 +245,12 @@ function register(connection, projects, features, initParams) {
241
245
  return __awaiter(this, void 0, void 0, function* () {
242
246
  const vueLs = yield getLanguageService(uri);
243
247
  if (vueLs) {
244
- return cb(vueLs);
248
+ try {
249
+ return cb(vueLs); // handle for TS cancel throw
250
+ }
251
+ catch (_a) {
252
+ return undefined;
253
+ }
245
254
  }
246
255
  });
247
256
  }
package/out/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from '@volar/language-service';
2
- export * from './requests';
1
+ export * from './protocol';
3
2
  export * from './types';
3
+ export * from '@volar/language-core/out/types';
4
+ export * from '@volar/language-service/out/types';
package/out/index.js CHANGED
@@ -13,7 +13,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
13
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- __exportStar(require("@volar/language-service"), exports);
17
- __exportStar(require("./requests"), exports);
16
+ __exportStar(require("./protocol"), exports);
18
17
  __exportStar(require("./types"), exports);
18
+ // only export types of depend packages
19
+ __exportStar(require("@volar/language-core/out/types"), exports);
20
+ __exportStar(require("@volar/language-service/out/types"), exports);
19
21
  //# sourceMappingURL=index.js.map
package/out/node.js CHANGED
@@ -17,7 +17,6 @@ exports.createLanguageServer = void 0;
17
17
  const shared = require("@volar/shared");
18
18
  const fs = require("fs");
19
19
  const request_light_1 = require("request-light");
20
- const path = require("upath");
21
20
  const html = require("vscode-html-languageservice");
22
21
  const vscode = require("vscode-languageserver/node");
23
22
  const server_1 = require("./server");
@@ -27,17 +26,22 @@ const nodeFileSystemHost_1 = require("./utils/nodeFileSystemHost");
27
26
  function createLanguageServer(plugins) {
28
27
  const connection = vscode.createConnection(vscode.ProposedFeatures.all);
29
28
  (0, server_1.createCommonLanguageServer)(connection, {
30
- loadTypescript(options) {
31
- return require(path.toUnix(options.typescript.serverPath));
32
- },
33
- loadTypescriptLocalized(options) {
34
- if (options.typescript.localizedPath) {
29
+ loadTypescript(tsdk) {
30
+ for (const name of ['./typescript.js', './tsserverlibrary.js', './tsserver.js']) {
35
31
  try {
36
- return require(path.toUnix(options.typescript.localizedPath));
32
+ const path = require.resolve(name, { paths: [tsdk] });
33
+ return require(path);
37
34
  }
38
35
  catch (_a) { }
39
36
  }
40
37
  },
38
+ loadTypescriptLocalized(tsdk, locale) {
39
+ try {
40
+ const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
41
+ return require(path);
42
+ }
43
+ catch (_a) { }
44
+ },
41
45
  schemaRequestHandlers: {
42
46
  file: file_1.default,
43
47
  http: http_1.default,
@@ -3,12 +3,6 @@ import type * as html from 'vscode-html-languageservice';
3
3
  /**
4
4
  * Server request client
5
5
  */
6
- export declare namespace GetDocumentContentRequest {
7
- type ParamsType = vscode.TextDocumentIdentifier;
8
- type ResponseType = string;
9
- type ErrorType = never;
10
- const type: vscode.RequestType<vscode.TextDocumentIdentifier, string, never>;
11
- }
12
6
  export declare namespace ShowReferencesNotification {
13
7
  type ResponseType = vscode.TextDocumentPositionParams & {
14
8
  references: vscode.Location[];
@@ -21,11 +15,6 @@ export declare namespace GetDocumentPrintWidthRequest {
21
15
  type ErrorType = never;
22
16
  const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
23
17
  }
24
- export declare namespace GetEditorSelectionRequest {
25
- type ResponseType = vscode.TextDocumentPositionParams | undefined;
26
- type ErrorType = never;
27
- const type: vscode.RequestType0<ResponseType, never>;
28
- }
29
18
  export declare namespace FindFileReferenceRequest {
30
19
  type ParamsType = {
31
20
  textDocument: vscode.TextDocumentIdentifier;
@@ -1,13 +1,9 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.GetEditorSelectionRequest = exports.GetDocumentPrintWidthRequest = exports.ShowReferencesNotification = exports.GetDocumentContentRequest = void 0;
2
+ exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.GetDocumentPrintWidthRequest = exports.ShowReferencesNotification = void 0;
3
3
  const vscode = require("vscode-languageserver-protocol");
4
4
  /**
5
5
  * Server request client
6
6
  */
7
- var GetDocumentContentRequest;
8
- (function (GetDocumentContentRequest) {
9
- GetDocumentContentRequest.type = new vscode.RequestType('vscode/content');
10
- })(GetDocumentContentRequest = exports.GetDocumentContentRequest || (exports.GetDocumentContentRequest = {}));
11
7
  var ShowReferencesNotification;
12
8
  (function (ShowReferencesNotification) {
13
9
  ShowReferencesNotification.type = new vscode.NotificationType('vue.findReferences');
@@ -16,10 +12,6 @@ var GetDocumentPrintWidthRequest;
16
12
  (function (GetDocumentPrintWidthRequest) {
17
13
  GetDocumentPrintWidthRequest.type = new vscode.RequestType('vue/getDocumentWordWrapColumn');
18
14
  })(GetDocumentPrintWidthRequest = exports.GetDocumentPrintWidthRequest || (exports.GetDocumentPrintWidthRequest = {}));
19
- var GetEditorSelectionRequest;
20
- (function (GetEditorSelectionRequest) {
21
- GetEditorSelectionRequest.type = new vscode.RequestType0('vue/activeSelection');
22
- })(GetEditorSelectionRequest = exports.GetEditorSelectionRequest || (exports.GetEditorSelectionRequest = {}));
23
15
  var FindFileReferenceRequest;
24
16
  (function (FindFileReferenceRequest) {
25
17
  FindFileReferenceRequest.type = new vscode.RequestType('vue/findFileReference');
@@ -62,4 +54,4 @@ var FsReadDirectoryRequest;
62
54
  (function (FsReadDirectoryRequest) {
63
55
  FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
64
56
  })(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
65
- //# sourceMappingURL=requests.js.map
57
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1,5 @@
1
+ import { LanguageServerPlugin, LanguageServerInitializationOptions } from './types';
2
+ import * as vscode from 'vscode-languageserver';
3
+ import { ClientCapabilities } from 'vscode-languageserver';
4
+ export declare function setupSyntacticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities): void;
5
+ export declare function setupSemanticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities, options: LanguageServerInitializationOptions, plugins: ReturnType<LanguageServerPlugin>[]): void;
@@ -0,0 +1,174 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.setupSemanticCapabilities = exports.setupSyntacticCapabilities = void 0;
3
+ const embedded = require("@volar/language-service");
4
+ const types_1 = require("./types");
5
+ const vscode = require("vscode-languageserver");
6
+ function setupSyntacticCapabilities(params, server) {
7
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8
+ if ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.selectionRange) {
9
+ server.selectionRangeProvider = true;
10
+ }
11
+ if ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.foldingRange) {
12
+ server.foldingRangeProvider = true;
13
+ }
14
+ if ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.linkedEditingRange) {
15
+ server.linkedEditingRangeProvider = true;
16
+ }
17
+ if ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.colorProvider) {
18
+ server.colorProvider = true;
19
+ }
20
+ if ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.documentSymbol) {
21
+ server.documentSymbolProvider = true;
22
+ }
23
+ if ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.formatting) {
24
+ server.documentFormattingProvider = true;
25
+ }
26
+ if ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rangeFormatting) {
27
+ server.documentRangeFormattingProvider = true;
28
+ }
29
+ if ((_h = params.textDocument) === null || _h === void 0 ? void 0 : _h.onTypeFormatting) {
30
+ // https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
31
+ server.documentOnTypeFormattingProvider = {
32
+ firstTriggerCharacter: ';',
33
+ moreTriggerCharacter: ['}', '\n'],
34
+ };
35
+ }
36
+ }
37
+ exports.setupSyntacticCapabilities = setupSyntacticCapabilities;
38
+ function setupSemanticCapabilities(params, server, options, plugins) {
39
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
40
+ if ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.references) {
41
+ server.referencesProvider = true;
42
+ }
43
+ if ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.implementation) {
44
+ server.implementationProvider = true;
45
+ }
46
+ if ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.definition) {
47
+ server.definitionProvider = true;
48
+ }
49
+ if ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.typeDefinition) {
50
+ server.typeDefinitionProvider = true;
51
+ }
52
+ if ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.callHierarchy) {
53
+ server.callHierarchyProvider = true;
54
+ }
55
+ if ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.hover) {
56
+ server.hoverProvider = true;
57
+ }
58
+ if ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rename) {
59
+ server.renameProvider = {
60
+ prepareProvider: true,
61
+ };
62
+ }
63
+ if ((_h = params.workspace) === null || _h === void 0 ? void 0 : _h.fileOperations) {
64
+ server.workspace = {
65
+ fileOperations: {
66
+ willRename: {
67
+ filters: [
68
+ ...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: { glob: `**/*.${ext.extension}` } }))).flat(),
69
+ { pattern: { glob: '**/*.js' } },
70
+ { pattern: { glob: '**/*.ts' } },
71
+ { pattern: { glob: '**/*.jsx' } },
72
+ { pattern: { glob: '**/*.tsx' } },
73
+ { pattern: { glob: '**/*.json' } },
74
+ ]
75
+ }
76
+ }
77
+ };
78
+ }
79
+ if ((_j = params.textDocument) === null || _j === void 0 ? void 0 : _j.signatureHelp) {
80
+ server.signatureHelpProvider = {
81
+ triggerCharacters: ['(', ',', '<'],
82
+ retriggerCharacters: [')'],
83
+ };
84
+ }
85
+ if ((_k = params.textDocument) === null || _k === void 0 ? void 0 : _k.completion) {
86
+ server.completionProvider = {
87
+ // triggerCharacters: '!@#$%^&*()_+-=`~{}|[]\:";\'<>?,./ '.split(''), // all symbols on keyboard
88
+ // hardcode to fix https://github.com/sublimelsp/LSP-volar/issues/114
89
+ triggerCharacters: [...new Set([
90
+ '/', '-', ':',
91
+ ...'>+^*()#.[]$@-{}'.split(''),
92
+ '.', ':', '<', '"', '=', '/',
93
+ '@',
94
+ '"', ':',
95
+ '.', '"', '\'', '`', '/', '<', '@', '#', ' ',
96
+ '*',
97
+ '@', // typescript-comment
98
+ ])],
99
+ resolveProvider: true,
100
+ };
101
+ if (options.ignoreTriggerCharacters) {
102
+ server.completionProvider.triggerCharacters = (_l = server.completionProvider.triggerCharacters) === null || _l === void 0 ? void 0 : _l.filter(c => !options.ignoreTriggerCharacters.includes(c));
103
+ }
104
+ }
105
+ if ((_m = params.textDocument) === null || _m === void 0 ? void 0 : _m.documentHighlight) {
106
+ server.documentHighlightProvider = true;
107
+ }
108
+ if ((_o = params.textDocument) === null || _o === void 0 ? void 0 : _o.documentLink) {
109
+ server.documentLinkProvider = {
110
+ resolveProvider: false, // TODO
111
+ };
112
+ }
113
+ if ((_p = params.workspace) === null || _p === void 0 ? void 0 : _p.symbol) {
114
+ server.workspaceSymbolProvider = true;
115
+ }
116
+ if ((_q = params.textDocument) === null || _q === void 0 ? void 0 : _q.codeLens) {
117
+ server.codeLensProvider = {
118
+ resolveProvider: true,
119
+ };
120
+ server.executeCommandProvider = {
121
+ commands: [
122
+ ...(_s = (_r = server.executeCommandProvider) === null || _r === void 0 ? void 0 : _r.commands) !== null && _s !== void 0 ? _s : [],
123
+ embedded.executePluginCommand,
124
+ ]
125
+ };
126
+ }
127
+ if ((_t = params.textDocument) === null || _t === void 0 ? void 0 : _t.semanticTokens) {
128
+ server.semanticTokensProvider = {
129
+ range: true,
130
+ full: false,
131
+ legend: {
132
+ tokenModifiers: [],
133
+ tokenTypes: [],
134
+ },
135
+ };
136
+ for (const plugin of plugins) {
137
+ if ((_u = plugin.languageService) === null || _u === void 0 ? void 0 : _u.semanticTokenLegend) {
138
+ server.semanticTokensProvider.legend.tokenModifiers = server.semanticTokensProvider.legend.tokenModifiers.concat(plugin.languageService.semanticTokenLegend.tokenModifiers);
139
+ server.semanticTokensProvider.legend.tokenTypes = server.semanticTokensProvider.legend.tokenTypes.concat(plugin.languageService.semanticTokenLegend.tokenTypes);
140
+ }
141
+ }
142
+ }
143
+ if ((_v = params.textDocument) === null || _v === void 0 ? void 0 : _v.codeAction) {
144
+ server.codeActionProvider = {
145
+ codeActionKinds: [
146
+ vscode.CodeActionKind.Empty,
147
+ vscode.CodeActionKind.QuickFix,
148
+ vscode.CodeActionKind.Refactor,
149
+ vscode.CodeActionKind.RefactorExtract,
150
+ vscode.CodeActionKind.RefactorInline,
151
+ vscode.CodeActionKind.RefactorRewrite,
152
+ vscode.CodeActionKind.Source,
153
+ vscode.CodeActionKind.SourceFixAll,
154
+ vscode.CodeActionKind.SourceOrganizeImports,
155
+ ],
156
+ resolveProvider: true,
157
+ };
158
+ }
159
+ if ((_w = params.textDocument) === null || _w === void 0 ? void 0 : _w.inlayHint) {
160
+ server.inlayHintProvider = true;
161
+ }
162
+ if (((_x = params.textDocument) === null || _x === void 0 ? void 0 : _x.diagnostic) && ((_y = options.diagnosticModel) !== null && _y !== void 0 ? _y : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
163
+ server.diagnosticProvider = {
164
+ documentSelector: [
165
+ ...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: `**/*.${ext.extension}` }))).flat(),
166
+ { pattern: '**/*.{ts,js,tsx,jsx}' },
167
+ ],
168
+ interFileDependencies: true,
169
+ workspaceDiagnostics: false,
170
+ };
171
+ }
172
+ }
173
+ exports.setupSemanticCapabilities = setupSemanticCapabilities;
174
+ //# sourceMappingURL=registerFeatures.js.map