@volar/language-server 1.0.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/LICENSE +21 -0
- package/out/browser.d.ts +3 -0
- package/out/browser.js +47 -0
- package/out/features/customFeatures.d.ts +4 -0
- package/out/features/customFeatures.js +83 -0
- package/out/features/documentFeatures.d.ts +4 -0
- package/out/features/documentFeatures.js +73 -0
- package/out/features/languageFeatures.d.ts +4 -0
- package/out/features/languageFeatures.js +274 -0
- package/out/index.d.ts +3 -0
- package/out/index.js +19 -0
- package/out/node.d.ts +3 -0
- package/out/node.js +88 -0
- package/out/registers/registerDocumentFeatures.d.ts +3 -0
- package/out/registers/registerDocumentFeatures.js +30 -0
- package/out/registers/registerlanguageFeatures.d.ts +3 -0
- package/out/registers/registerlanguageFeatures.js +144 -0
- package/out/requests.d.ts +81 -0
- package/out/requests.js +65 -0
- package/out/schemaRequestHandlers/file.d.ts +2 -0
- package/out/schemaRequestHandlers/file.js +12 -0
- package/out/schemaRequestHandlers/http.d.ts +1 -0
- package/out/schemaRequestHandlers/http.js +12 -0
- package/out/server.d.ts +3 -0
- package/out/server.js +99 -0
- package/out/types.d.ts +112 -0
- package/out/types.js +2 -0
- package/out/utils/config.d.ts +2 -0
- package/out/utils/config.js +17 -0
- package/out/utils/configurationHost.d.ts +5 -0
- package/out/utils/configurationHost.js +38 -0
- package/out/utils/documentServiceHost.d.ts +30 -0
- package/out/utils/documentServiceHost.js +51 -0
- package/out/utils/inferredCompilerOptions.d.ts +3 -0
- package/out/utils/inferredCompilerOptions.js +71 -0
- package/out/utils/iterableWeakSet.d.ts +7 -0
- package/out/utils/iterableWeakSet.js +40 -0
- package/out/utils/nodeFileSystemHost.d.ts +3 -0
- package/out/utils/nodeFileSystemHost.js +95 -0
- package/out/utils/project.d.ts +99 -0
- package/out/utils/project.js +273 -0
- package/out/utils/snapshots.d.ts +45 -0
- package/out/utils/snapshots.js +201 -0
- package/out/utils/ts/core.d.ts +83 -0
- package/out/utils/ts/core.js +319 -0
- package/out/utils/ts/corePublic.d.ts +91 -0
- package/out/utils/ts/corePublic.js +50 -0
- package/out/utils/ts/path.d.ts +112 -0
- package/out/utils/ts/path.js +416 -0
- package/out/utils/ts/types.d.ts +129 -0
- package/out/utils/ts/types.js +2 -0
- package/out/utils/ts/utilities.d.ts +7 -0
- package/out/utils/ts/utilities.js +249 -0
- package/out/utils/webFileSystemHost.d.ts +2 -0
- package/out/utils/webFileSystemHost.js +265 -0
- package/out/utils/workspaceProjects.d.ts +120 -0
- package/out/utils/workspaceProjects.js +226 -0
- package/out/utils/workspaces.d.ts +309 -0
- package/out/utils/workspaces.js +154 -0
- package/package.json +27 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.register = void 0;
|
|
3
|
+
function register(features, server) {
|
|
4
|
+
if (features.selectionRange) {
|
|
5
|
+
server.selectionRangeProvider = true;
|
|
6
|
+
}
|
|
7
|
+
if (features.foldingRange) {
|
|
8
|
+
server.foldingRangeProvider = true;
|
|
9
|
+
}
|
|
10
|
+
if (features.linkedEditingRange) {
|
|
11
|
+
server.linkedEditingRangeProvider = true;
|
|
12
|
+
}
|
|
13
|
+
if (features.documentColor) {
|
|
14
|
+
server.colorProvider = true;
|
|
15
|
+
}
|
|
16
|
+
if (features.documentSymbol) {
|
|
17
|
+
server.documentSymbolProvider = true;
|
|
18
|
+
}
|
|
19
|
+
if (features.documentFormatting) {
|
|
20
|
+
server.documentFormattingProvider = true;
|
|
21
|
+
server.documentRangeFormattingProvider = true;
|
|
22
|
+
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
|
|
23
|
+
server.documentOnTypeFormattingProvider = {
|
|
24
|
+
firstTriggerCharacter: ';',
|
|
25
|
+
moreTriggerCharacter: ['}', '\n'],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.register = register;
|
|
30
|
+
//# sourceMappingURL=registerDocumentFeatures.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { LanguageServerPlugin, ServerInitializationOptions } from '../types';
|
|
2
|
+
import * as vscode from 'vscode-languageserver';
|
|
3
|
+
export declare function register(features: NonNullable<ServerInitializationOptions['languageFeatures']>, server: vscode.ServerCapabilities, plugins: ReturnType<LanguageServerPlugin>[]): void;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.register = void 0;
|
|
3
|
+
const embedded = require("@volar/language-service");
|
|
4
|
+
const vscode = require("vscode-languageserver");
|
|
5
|
+
function register(features, server, plugins) {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
if (features.references) {
|
|
8
|
+
server.referencesProvider = true;
|
|
9
|
+
}
|
|
10
|
+
if (features.implementation) {
|
|
11
|
+
server.implementationProvider = true;
|
|
12
|
+
}
|
|
13
|
+
if (features.definition) {
|
|
14
|
+
server.definitionProvider = true;
|
|
15
|
+
}
|
|
16
|
+
if (features.typeDefinition) {
|
|
17
|
+
server.typeDefinitionProvider = true;
|
|
18
|
+
}
|
|
19
|
+
if (features.callHierarchy) {
|
|
20
|
+
server.callHierarchyProvider = true;
|
|
21
|
+
}
|
|
22
|
+
if (features.hover) {
|
|
23
|
+
server.hoverProvider = true;
|
|
24
|
+
}
|
|
25
|
+
if (features.rename) {
|
|
26
|
+
server.renameProvider = {
|
|
27
|
+
prepareProvider: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (features.renameFileRefactoring) {
|
|
31
|
+
server.workspace = {
|
|
32
|
+
fileOperations: {
|
|
33
|
+
willRename: {
|
|
34
|
+
filters: [
|
|
35
|
+
...plugins.map(plugin => plugin.extensions.map(ext => ({ pattern: { glob: `**/*${ext}` } }))).flat(),
|
|
36
|
+
{ pattern: { glob: '**/*.js' } },
|
|
37
|
+
{ pattern: { glob: '**/*.ts' } },
|
|
38
|
+
{ pattern: { glob: '**/*.jsx' } },
|
|
39
|
+
{ pattern: { glob: '**/*.tsx' } },
|
|
40
|
+
{ pattern: { glob: '**/*.json' } },
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (features.signatureHelp) {
|
|
47
|
+
server.signatureHelpProvider = {
|
|
48
|
+
triggerCharacters: ['(', ',', '<'],
|
|
49
|
+
retriggerCharacters: [')'],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (features.completion) {
|
|
53
|
+
server.completionProvider = {
|
|
54
|
+
// triggerCharacters: '!@#$%^&*()_+-=`~{}|[]\:";\'<>?,./ '.split(''), // all symbols on keyboard
|
|
55
|
+
// hardcode to fix https://github.com/sublimelsp/LSP-volar/issues/114
|
|
56
|
+
triggerCharacters: [...new Set([
|
|
57
|
+
'/', '-', ':',
|
|
58
|
+
...'>+^*()#.[]$@-{}'.split(''),
|
|
59
|
+
'.', ':', '<', '"', '=', '/',
|
|
60
|
+
'@',
|
|
61
|
+
'"', ':',
|
|
62
|
+
'.', '"', '\'', '`', '/', '<', '@', '#', ' ',
|
|
63
|
+
'*',
|
|
64
|
+
'@', // typescript-comment
|
|
65
|
+
])],
|
|
66
|
+
resolveProvider: true,
|
|
67
|
+
};
|
|
68
|
+
if (typeof features.completion === 'object' && features.completion.ignoreTriggerCharacters) {
|
|
69
|
+
const ignores = features.completion.ignoreTriggerCharacters;
|
|
70
|
+
server.completionProvider.triggerCharacters = (_a = server.completionProvider.triggerCharacters) === null || _a === void 0 ? void 0 : _a.filter(c => !ignores.includes(c));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (features.documentHighlight) {
|
|
74
|
+
server.documentHighlightProvider = true;
|
|
75
|
+
}
|
|
76
|
+
if (features.documentLink) {
|
|
77
|
+
server.documentLinkProvider = {
|
|
78
|
+
resolveProvider: false, // TODO
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (features.workspaceSymbol) {
|
|
82
|
+
server.workspaceSymbolProvider = true;
|
|
83
|
+
}
|
|
84
|
+
if (features.codeLens) {
|
|
85
|
+
server.codeLensProvider = {
|
|
86
|
+
resolveProvider: true,
|
|
87
|
+
};
|
|
88
|
+
server.executeCommandProvider = {
|
|
89
|
+
commands: [
|
|
90
|
+
...((_c = (_b = server.executeCommandProvider) === null || _b === void 0 ? void 0 : _b.commands) !== null && _c !== void 0 ? _c : []),
|
|
91
|
+
embedded.executePluginCommand,
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (features.semanticTokens) {
|
|
96
|
+
server.semanticTokensProvider = {
|
|
97
|
+
range: true,
|
|
98
|
+
full: false,
|
|
99
|
+
legend: {
|
|
100
|
+
tokenModifiers: [],
|
|
101
|
+
tokenTypes: [],
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
for (const plugin of plugins) {
|
|
105
|
+
if ((_d = plugin.languageService) === null || _d === void 0 ? void 0 : _d.semanticTokenLegend) {
|
|
106
|
+
server.semanticTokensProvider.legend.tokenModifiers = server.semanticTokensProvider.legend.tokenModifiers.concat(plugin.languageService.semanticTokenLegend.tokenModifiers);
|
|
107
|
+
server.semanticTokensProvider.legend.tokenTypes = server.semanticTokensProvider.legend.tokenTypes.concat(plugin.languageService.semanticTokenLegend.tokenTypes);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (features.codeAction) {
|
|
112
|
+
server.codeActionProvider = {
|
|
113
|
+
codeActionKinds: [
|
|
114
|
+
vscode.CodeActionKind.Empty,
|
|
115
|
+
vscode.CodeActionKind.QuickFix,
|
|
116
|
+
vscode.CodeActionKind.Refactor,
|
|
117
|
+
vscode.CodeActionKind.RefactorExtract,
|
|
118
|
+
vscode.CodeActionKind.RefactorInline,
|
|
119
|
+
vscode.CodeActionKind.RefactorRewrite,
|
|
120
|
+
vscode.CodeActionKind.Source,
|
|
121
|
+
vscode.CodeActionKind.SourceFixAll,
|
|
122
|
+
vscode.CodeActionKind.SourceOrganizeImports,
|
|
123
|
+
],
|
|
124
|
+
resolveProvider: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (features.inlayHints) {
|
|
128
|
+
server.inlayHintProvider = true;
|
|
129
|
+
}
|
|
130
|
+
// buggy
|
|
131
|
+
// if (features.diagnostics) {
|
|
132
|
+
// server.diagnosticProvider = {
|
|
133
|
+
// documentSelector: [
|
|
134
|
+
// ...languageConfigs.definitelyExts.map(ext => ({ pattern: `**/*${ext}` })),
|
|
135
|
+
// ...languageConfigs.indeterminateExts.map(ext => ({ pattern: `**/*${ext}` })),
|
|
136
|
+
// { pattern: '**/*.{ts,js,tsx,jsx}' },
|
|
137
|
+
// ],
|
|
138
|
+
// interFileDependencies: true,
|
|
139
|
+
// workspaceDiagnostics: false,
|
|
140
|
+
// };
|
|
141
|
+
// }
|
|
142
|
+
}
|
|
143
|
+
exports.register = register;
|
|
144
|
+
//# sourceMappingURL=registerlanguageFeatures.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type * as html from 'vscode-html-languageservice';
|
|
3
|
+
/**
|
|
4
|
+
* Server request client
|
|
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
|
+
export declare namespace ShowReferencesNotification {
|
|
13
|
+
type ResponseType = vscode.TextDocumentPositionParams & {
|
|
14
|
+
references: vscode.Location[];
|
|
15
|
+
};
|
|
16
|
+
const type: vscode.NotificationType<ResponseType>;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace GetDocumentPrintWidthRequest {
|
|
19
|
+
type ParamsType = vscode.TextDocumentIdentifier;
|
|
20
|
+
type ResponseType = number | undefined;
|
|
21
|
+
type ErrorType = never;
|
|
22
|
+
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
23
|
+
}
|
|
24
|
+
export declare namespace GetEditorSelectionRequest {
|
|
25
|
+
type ResponseType = vscode.TextDocumentPositionParams | undefined;
|
|
26
|
+
type ErrorType = never;
|
|
27
|
+
const type: vscode.RequestType0<ResponseType, never>;
|
|
28
|
+
}
|
|
29
|
+
export declare namespace FindFileReferenceRequest {
|
|
30
|
+
type ParamsType = {
|
|
31
|
+
textDocument: vscode.TextDocumentIdentifier;
|
|
32
|
+
};
|
|
33
|
+
type ResponseType = vscode.Location[] | null | undefined;
|
|
34
|
+
type ErrorType = never;
|
|
35
|
+
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Client request server
|
|
39
|
+
*/
|
|
40
|
+
export declare namespace GetMatchTsConfigRequest {
|
|
41
|
+
type ParamsType = vscode.TextDocumentIdentifier;
|
|
42
|
+
type ResponseType = string | null | undefined;
|
|
43
|
+
type ErrorType = never;
|
|
44
|
+
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
45
|
+
}
|
|
46
|
+
export declare namespace AutoInsertRequest {
|
|
47
|
+
type ParamsType = vscode.TextDocumentPositionParams & {
|
|
48
|
+
options: {
|
|
49
|
+
lastChange: {
|
|
50
|
+
range: vscode.Range;
|
|
51
|
+
rangeOffset: number;
|
|
52
|
+
rangeLength: number;
|
|
53
|
+
text: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type ResponseType = string | vscode.TextEdit | null | undefined;
|
|
58
|
+
type ErrorType = never;
|
|
59
|
+
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
60
|
+
}
|
|
61
|
+
export declare namespace VerifyAllScriptsNotification {
|
|
62
|
+
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
63
|
+
}
|
|
64
|
+
export declare namespace WriteVirtualFilesNotification {
|
|
65
|
+
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
66
|
+
}
|
|
67
|
+
export declare namespace ReloadProjectNotification {
|
|
68
|
+
const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* FS request for browser
|
|
72
|
+
*/
|
|
73
|
+
export declare namespace FsStatRequest {
|
|
74
|
+
const type: vscode.RequestType<string, html.FileStat | undefined, unknown>;
|
|
75
|
+
}
|
|
76
|
+
export declare namespace FsReadFileRequest {
|
|
77
|
+
const type: vscode.RequestType<string, string | undefined, unknown>;
|
|
78
|
+
}
|
|
79
|
+
export declare namespace FsReadDirectoryRequest {
|
|
80
|
+
const type: vscode.RequestType<string, [string, html.FileType][], unknown>;
|
|
81
|
+
}
|
package/out/requests.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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;
|
|
3
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
4
|
+
/**
|
|
5
|
+
* Server request client
|
|
6
|
+
*/
|
|
7
|
+
var GetDocumentContentRequest;
|
|
8
|
+
(function (GetDocumentContentRequest) {
|
|
9
|
+
GetDocumentContentRequest.type = new vscode.RequestType('vscode/content');
|
|
10
|
+
})(GetDocumentContentRequest = exports.GetDocumentContentRequest || (exports.GetDocumentContentRequest = {}));
|
|
11
|
+
var ShowReferencesNotification;
|
|
12
|
+
(function (ShowReferencesNotification) {
|
|
13
|
+
ShowReferencesNotification.type = new vscode.NotificationType('vue.findReferences');
|
|
14
|
+
})(ShowReferencesNotification = exports.ShowReferencesNotification || (exports.ShowReferencesNotification = {}));
|
|
15
|
+
var GetDocumentPrintWidthRequest;
|
|
16
|
+
(function (GetDocumentPrintWidthRequest) {
|
|
17
|
+
GetDocumentPrintWidthRequest.type = new vscode.RequestType('vue/getDocumentWordWrapColumn');
|
|
18
|
+
})(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
|
+
var FindFileReferenceRequest;
|
|
24
|
+
(function (FindFileReferenceRequest) {
|
|
25
|
+
FindFileReferenceRequest.type = new vscode.RequestType('vue/findFileReference');
|
|
26
|
+
})(FindFileReferenceRequest = exports.FindFileReferenceRequest || (exports.FindFileReferenceRequest = {}));
|
|
27
|
+
/**
|
|
28
|
+
* Client request server
|
|
29
|
+
*/
|
|
30
|
+
var GetMatchTsConfigRequest;
|
|
31
|
+
(function (GetMatchTsConfigRequest) {
|
|
32
|
+
GetMatchTsConfigRequest.type = new vscode.RequestType('volar/tsconfig');
|
|
33
|
+
})(GetMatchTsConfigRequest = exports.GetMatchTsConfigRequest || (exports.GetMatchTsConfigRequest = {}));
|
|
34
|
+
var AutoInsertRequest;
|
|
35
|
+
(function (AutoInsertRequest) {
|
|
36
|
+
AutoInsertRequest.type = new vscode.RequestType('vue/autoInsert');
|
|
37
|
+
})(AutoInsertRequest = exports.AutoInsertRequest || (exports.AutoInsertRequest = {}));
|
|
38
|
+
var VerifyAllScriptsNotification;
|
|
39
|
+
(function (VerifyAllScriptsNotification) {
|
|
40
|
+
VerifyAllScriptsNotification.type = new vscode.NotificationType('volar.action.verifyAllScripts');
|
|
41
|
+
})(VerifyAllScriptsNotification = exports.VerifyAllScriptsNotification || (exports.VerifyAllScriptsNotification = {}));
|
|
42
|
+
var WriteVirtualFilesNotification;
|
|
43
|
+
(function (WriteVirtualFilesNotification) {
|
|
44
|
+
WriteVirtualFilesNotification.type = new vscode.NotificationType('volar.action.writeVirtualFiles');
|
|
45
|
+
})(WriteVirtualFilesNotification = exports.WriteVirtualFilesNotification || (exports.WriteVirtualFilesNotification = {}));
|
|
46
|
+
var ReloadProjectNotification;
|
|
47
|
+
(function (ReloadProjectNotification) {
|
|
48
|
+
ReloadProjectNotification.type = new vscode.NotificationType('volar.action.reloadProject');
|
|
49
|
+
})(ReloadProjectNotification = exports.ReloadProjectNotification || (exports.ReloadProjectNotification = {}));
|
|
50
|
+
/**
|
|
51
|
+
* FS request for browser
|
|
52
|
+
*/
|
|
53
|
+
var FsStatRequest;
|
|
54
|
+
(function (FsStatRequest) {
|
|
55
|
+
FsStatRequest.type = new vscode.RequestType('fs/stat');
|
|
56
|
+
})(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
|
|
57
|
+
var FsReadFileRequest;
|
|
58
|
+
(function (FsReadFileRequest) {
|
|
59
|
+
FsReadFileRequest.type = new vscode.RequestType('fs/readFile');
|
|
60
|
+
})(FsReadFileRequest = exports.FsReadFileRequest || (exports.FsReadFileRequest = {}));
|
|
61
|
+
var FsReadDirectoryRequest;
|
|
62
|
+
(function (FsReadDirectoryRequest) {
|
|
63
|
+
FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
|
|
64
|
+
})(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
|
|
65
|
+
//# sourceMappingURL=requests.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
4
|
+
function handler(uri, encoding) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
fs.readFile(vscode_uri_1.URI.parse(uri).fsPath, { encoding }, (err, buf) => {
|
|
7
|
+
err ? reject(err) : resolve(buf.toString());
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.default = handler;
|
|
12
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function handler(uri: string): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const request_light_1 = require("request-light");
|
|
3
|
+
function handler(uri) {
|
|
4
|
+
const headers = { 'Accept-Encoding': 'gzip, deflate' };
|
|
5
|
+
return (0, request_light_1.xhr)({ url: uri, followRedirects: 5, headers }).then(response => {
|
|
6
|
+
return response.responseText;
|
|
7
|
+
}, (error) => {
|
|
8
|
+
return Promise.reject(error.responseText || (0, request_light_1.getErrorStatusDescription)(error.status) || error.toString());
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.default = handler;
|
|
12
|
+
//# sourceMappingURL=http.js.map
|
package/out/server.d.ts
ADDED
package/out/server.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.createCommonLanguageServer = void 0;
|
|
12
|
+
const vscode = require("vscode-languageserver");
|
|
13
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
14
|
+
const configurationHost_1 = require("./utils/configurationHost");
|
|
15
|
+
const documentServiceHost_1 = require("./utils/documentServiceHost");
|
|
16
|
+
const snapshots_1 = require("./utils/snapshots");
|
|
17
|
+
const workspaces_1 = require("./utils/workspaces");
|
|
18
|
+
function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
19
|
+
let params;
|
|
20
|
+
let options;
|
|
21
|
+
let roots = [];
|
|
22
|
+
let fsHost;
|
|
23
|
+
let projects;
|
|
24
|
+
let documentServiceHost;
|
|
25
|
+
let configHost;
|
|
26
|
+
let plugins;
|
|
27
|
+
const documents = (0, snapshots_1.createSnapshots)(connection);
|
|
28
|
+
connection.onInitialize((_params) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
params = _params;
|
|
31
|
+
options = params.initializationOptions;
|
|
32
|
+
plugins = _plugins.map(plugin => plugin(options));
|
|
33
|
+
if (((_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.workspaceFolders) && params.workspaceFolders) {
|
|
34
|
+
roots = params.workspaceFolders.map(folder => vscode_uri_1.URI.parse(folder.uri));
|
|
35
|
+
}
|
|
36
|
+
else if (params.rootUri) {
|
|
37
|
+
roots = [vscode_uri_1.URI.parse(params.rootUri)];
|
|
38
|
+
}
|
|
39
|
+
else if (params.rootPath) {
|
|
40
|
+
roots = [vscode_uri_1.URI.file(params.rootPath)];
|
|
41
|
+
}
|
|
42
|
+
const result = {
|
|
43
|
+
capabilities: {
|
|
44
|
+
textDocumentSync: (_b = options.textDocumentSync) !== null && _b !== void 0 ? _b : vscode.TextDocumentSyncKind.Incremental,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const ts = runtimeEnv.loadTypescript(options);
|
|
48
|
+
configHost = ((_c = params.capabilities.workspace) === null || _c === void 0 ? void 0 : _c.configuration) ? (0, configurationHost_1.createConfigurationHost)(params, connection) : undefined;
|
|
49
|
+
if (options.documentFeatures) {
|
|
50
|
+
(yield Promise.resolve().then(() => require('./registers/registerDocumentFeatures'))).register(options.documentFeatures, result.capabilities);
|
|
51
|
+
documentServiceHost = (0, documentServiceHost_1.createDocumentServiceHost)(runtimeEnv, plugins, ts, configHost);
|
|
52
|
+
for (const root of roots) {
|
|
53
|
+
documentServiceHost.add(root);
|
|
54
|
+
}
|
|
55
|
+
(yield Promise.resolve().then(() => require('./features/documentFeatures'))).register(connection, documents, documentServiceHost);
|
|
56
|
+
}
|
|
57
|
+
if (options.languageFeatures) {
|
|
58
|
+
(yield Promise.resolve().then(() => require('./registers/registerlanguageFeatures'))).register(options.languageFeatures, result.capabilities, plugins);
|
|
59
|
+
fsHost = runtimeEnv.createFileSystemHost(ts, params.capabilities);
|
|
60
|
+
const tsLocalized = runtimeEnv.loadTypescriptLocalized(options);
|
|
61
|
+
projects = (0, workspaces_1.createWorkspaces)(runtimeEnv, plugins, fsHost, configHost, ts, tsLocalized, options, documents, connection);
|
|
62
|
+
for (const root of roots) {
|
|
63
|
+
projects.add(root);
|
|
64
|
+
}
|
|
65
|
+
(yield Promise.resolve().then(() => require('./features/customFeatures'))).register(connection, projects, plugins);
|
|
66
|
+
(yield Promise.resolve().then(() => require('./features/languageFeatures'))).register(connection, projects, options.languageFeatures, params);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
// show version on LSP logs
|
|
70
|
+
const packageJson = require('../package.json');
|
|
71
|
+
result.serverInfo = {
|
|
72
|
+
name: packageJson.name,
|
|
73
|
+
version: packageJson.version,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (_d) { }
|
|
77
|
+
return result;
|
|
78
|
+
}));
|
|
79
|
+
connection.onInitialized(() => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _e;
|
|
81
|
+
fsHost === null || fsHost === void 0 ? void 0 : fsHost.ready(connection);
|
|
82
|
+
configHost === null || configHost === void 0 ? void 0 : configHost.ready();
|
|
83
|
+
if ((_e = params.capabilities.workspace) === null || _e === void 0 ? void 0 : _e.workspaceFolders) {
|
|
84
|
+
connection.workspace.onDidChangeWorkspaceFolders(e => {
|
|
85
|
+
for (const folder of e.added) {
|
|
86
|
+
documentServiceHost === null || documentServiceHost === void 0 ? void 0 : documentServiceHost.add(vscode_uri_1.URI.parse(folder.uri));
|
|
87
|
+
projects === null || projects === void 0 ? void 0 : projects.add(vscode_uri_1.URI.parse(folder.uri));
|
|
88
|
+
}
|
|
89
|
+
for (const folder of e.removed) {
|
|
90
|
+
documentServiceHost === null || documentServiceHost === void 0 ? void 0 : documentServiceHost.remove(vscode_uri_1.URI.parse(folder.uri));
|
|
91
|
+
projects === null || projects === void 0 ? void 0 : projects.remove(vscode_uri_1.URI.parse(folder.uri));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
connection.listen();
|
|
97
|
+
}
|
|
98
|
+
exports.createCommonLanguageServer = createCommonLanguageServer;
|
|
99
|
+
//# sourceMappingURL=server.js.map
|
package/out/types.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as embeddedLS from '@volar/language-service';
|
|
3
|
+
import * as embedded from '@volar/language-core';
|
|
4
|
+
import type { FileSystemProvider } from 'vscode-html-languageservice';
|
|
5
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
|
+
import * as vscode from 'vscode-languageserver';
|
|
7
|
+
import type * as Requests from './requests';
|
|
8
|
+
import { URI } from 'vscode-uri';
|
|
9
|
+
export declare let __requests: typeof Requests;
|
|
10
|
+
export declare type FileSystemHost = {
|
|
11
|
+
ready(connection: vscode.Connection): void;
|
|
12
|
+
clearCache(): void;
|
|
13
|
+
getWorkspaceFileSystem(rootUri: URI): FileSystem;
|
|
14
|
+
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams, reason: 'lsp' | 'web-cache-updated') => void): () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare type FileSystem = Pick<ts.System, 'newLine' | 'useCaseSensitiveFileNames' | 'fileExists' | 'readFile' | 'readDirectory' | 'getCurrentDirectory' | 'realpath' | 'resolvePath'> & Partial<ts.System>;
|
|
17
|
+
export interface RuntimeEnvironment {
|
|
18
|
+
loadTypescript: (initOptions: ServerInitializationOptions) => typeof import('typescript/lib/tsserverlibrary');
|
|
19
|
+
loadTypescriptLocalized: (initOptions: ServerInitializationOptions) => any;
|
|
20
|
+
schemaRequestHandlers: {
|
|
21
|
+
[schema: string]: (uri: string, encoding?: BufferEncoding) => Promise<string>;
|
|
22
|
+
};
|
|
23
|
+
onDidChangeConfiguration?: (settings: any) => void;
|
|
24
|
+
fileSystemProvide: FileSystemProvider | undefined;
|
|
25
|
+
createFileSystemHost: (ts: typeof import('typescript/lib/tsserverlibrary'), capabilities: vscode.ClientCapabilities) => FileSystemHost;
|
|
26
|
+
}
|
|
27
|
+
export declare type LanguageServerPlugin<A extends ServerInitializationOptions = ServerInitializationOptions, B extends embedded.LanguageServiceHost = embedded.LanguageServiceHost, C = embeddedLS.LanguageService> = (initOptions: A) => {
|
|
28
|
+
extensions: string[];
|
|
29
|
+
languageService?: {
|
|
30
|
+
semanticTokenLegend?: vscode.SemanticTokensLegend;
|
|
31
|
+
resolveLanguageServiceHost?(ts: typeof import('typescript/lib/tsserverlibrary'), sys: FileSystem, tsConfig: string | ts.CompilerOptions, host: embedded.LanguageServiceHost): B;
|
|
32
|
+
getLanguageModules?(host: B): embedded.EmbeddedLanguageModule[];
|
|
33
|
+
getServicePlugins?(host: B, service: embeddedLS.LanguageService): embeddedLS.EmbeddedLanguageServicePlugin[];
|
|
34
|
+
onInitialize?(connection: vscode.Connection, getLangaugeService: (uri: string) => Promise<C>): void;
|
|
35
|
+
};
|
|
36
|
+
documentService?: {
|
|
37
|
+
getLanguageModules?(ts: typeof import('typescript/lib/tsserverlibrary'), env: embeddedLS.PluginContext['env']): embedded.EmbeddedLanguageModule[];
|
|
38
|
+
getServicePlugins?(context: embeddedLS.DocumentServiceRuntimeContext): embeddedLS.EmbeddedLanguageServicePlugin[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export interface ServerInitializationOptions {
|
|
42
|
+
textDocumentSync?: vscode.TextDocumentSyncKind | number;
|
|
43
|
+
typescript: {
|
|
44
|
+
/**
|
|
45
|
+
* Path to tsserverlibrary.js / tsserver.js / typescript.js
|
|
46
|
+
* @example
|
|
47
|
+
* '/usr/local/lib/node_modules/typescript/lib/tsserverlibrary.js' // use global typescript install
|
|
48
|
+
* 'typescript/lib/tsserverlibrary.js' // if `typescript` exist in `@volar/vue-lannguage-server` itself node_modules directory
|
|
49
|
+
* '../../../typescript/lib/tsserverlibrary.js' // relative path to @volar/vue-language-server/out/index.js
|
|
50
|
+
*/
|
|
51
|
+
serverPath: string;
|
|
52
|
+
/**
|
|
53
|
+
* Path to lib/xxx/diagnosticMessages.generated.json
|
|
54
|
+
* @example
|
|
55
|
+
* '/usr/local/lib/node_modules/typescript/lib/ja/diagnosticMessages.generated.json' // use global typescript install
|
|
56
|
+
* 'typescript/lib/ja/diagnosticMessages.generated.json' // if `typescript` exist in `@volar/vue-lannguage-server` itself node_modules directory
|
|
57
|
+
* '../../../typescript/lib/ja/diagnosticMessages.generated.json' // relative path to @volar/vue-language-server/out/index.js
|
|
58
|
+
*/
|
|
59
|
+
localizedPath?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* typescript, html, css... language service will be create in server if this option is not null
|
|
63
|
+
*/
|
|
64
|
+
languageFeatures?: {
|
|
65
|
+
references?: boolean;
|
|
66
|
+
implementation?: boolean;
|
|
67
|
+
definition?: boolean;
|
|
68
|
+
typeDefinition?: boolean;
|
|
69
|
+
callHierarchy?: boolean;
|
|
70
|
+
hover?: boolean;
|
|
71
|
+
rename?: boolean;
|
|
72
|
+
renameFileRefactoring?: boolean;
|
|
73
|
+
signatureHelp?: boolean;
|
|
74
|
+
completion?: boolean | {
|
|
75
|
+
/**
|
|
76
|
+
* {@link __requests.GetDocumentSelectionRequest}
|
|
77
|
+
* */
|
|
78
|
+
getDocumentSelectionRequest?: boolean;
|
|
79
|
+
ignoreTriggerCharacters?: string;
|
|
80
|
+
};
|
|
81
|
+
documentHighlight?: boolean;
|
|
82
|
+
documentLink?: boolean;
|
|
83
|
+
workspaceSymbol?: boolean;
|
|
84
|
+
codeLens?: boolean | {
|
|
85
|
+
/**
|
|
86
|
+
* {@link __requests.ShowReferencesNotification}
|
|
87
|
+
* */
|
|
88
|
+
showReferencesNotification?: boolean;
|
|
89
|
+
};
|
|
90
|
+
semanticTokens?: boolean;
|
|
91
|
+
codeAction?: boolean;
|
|
92
|
+
inlayHints?: boolean;
|
|
93
|
+
diagnostics?: boolean;
|
|
94
|
+
schemaRequestService?: boolean | {
|
|
95
|
+
/**
|
|
96
|
+
* {@link __requests.GetDocumentContentRequest}
|
|
97
|
+
* */
|
|
98
|
+
getDocumentContentRequest?: boolean;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* html language service will be create in server if this option is not null
|
|
103
|
+
*/
|
|
104
|
+
documentFeatures?: {
|
|
105
|
+
selectionRange?: boolean;
|
|
106
|
+
foldingRange?: boolean;
|
|
107
|
+
linkedEditingRange?: boolean;
|
|
108
|
+
documentSymbol?: boolean;
|
|
109
|
+
documentColor?: boolean;
|
|
110
|
+
documentFormatting?: boolean;
|
|
111
|
+
};
|
|
112
|
+
}
|
package/out/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.loadCustomPlugins = void 0;
|
|
3
|
+
function loadCustomPlugins(dir) {
|
|
4
|
+
var _a;
|
|
5
|
+
try {
|
|
6
|
+
const configPath = require.resolve('./volar.config.js', { paths: [dir] });
|
|
7
|
+
const config = require(configPath);
|
|
8
|
+
// console.warn('Found', configPath, 'and loaded', config.plugins?.length, 'plugins.');
|
|
9
|
+
return (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
// console.warn('No volar.config.js found in', dir);
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.loadCustomPlugins = loadCustomPlugins;
|
|
17
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { ConfigurationHost } from '@volar/vue-language-service';
|
|
3
|
+
export declare function createConfigurationHost(params: vscode.InitializeParams, connection: vscode.Connection): ConfigurationHost & {
|
|
4
|
+
ready(): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.createConfigurationHost = void 0;
|
|
12
|
+
const vscode = require("vscode-languageserver");
|
|
13
|
+
function createConfigurationHost(params, connection) {
|
|
14
|
+
const callbacks = [];
|
|
15
|
+
connection.onDidChangeConfiguration(() => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
for (const cb of callbacks) {
|
|
17
|
+
cb();
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
return {
|
|
21
|
+
ready() {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
if ((_b = (_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration) === null || _b === void 0 ? void 0 : _b.dynamicRegistration) {
|
|
24
|
+
connection.client.register(vscode.DidChangeConfigurationNotification.type);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
getConfiguration(section, scopeUri) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return yield connection.workspace.getConfiguration({ scopeUri, section });
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
onDidChangeConfiguration(cb) {
|
|
33
|
+
callbacks.push(cb);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.createConfigurationHost = createConfigurationHost;
|
|
38
|
+
//# sourceMappingURL=configurationHost.js.map
|