-
-
Notifications
You must be signed in to change notification settings - Fork 371
/
types.ts
122 lines (104 loc) · 3.55 KB
/
types.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import * as embeddedLS from '@volar/language-service';
import * as embedded from '@volar/language-core';
import type { FileSystemProvider } from 'vscode-html-languageservice';
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vscode from 'vscode-languageserver';
import type * as Requests from './protocol';
import { URI } from 'vscode-uri';
export declare let __requests: typeof Requests; // keep this code for jsdoc link
export type FileSystemHost = {
ready(connection: vscode.Connection): void,
clearCache(): void,
getWorkspaceFileSystem(rootUri: URI): FileSystem,
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void,
};
export type FileSystem = Pick<ts.System,
'newLine'
| 'useCaseSensitiveFileNames'
| 'fileExists'
| 'readFile'
| 'readDirectory'
| 'getCurrentDirectory'
| 'realpath'
| 'resolvePath'
> & Partial<ts.System>;
export interface RuntimeEnvironment {
loadTypescript: (tsdk: string) => typeof import('typescript/lib/tsserverlibrary'),
loadTypescriptLocalized: (tsdk: string, locale: string) => Promise<{} | undefined>,
schemaRequestHandlers: { [schema: string]: (uri: string, encoding?: BufferEncoding) => Promise<string>; },
onDidChangeConfiguration?: (settings: any) => void,
fileSystemProvide: FileSystemProvider | undefined,
createFileSystemHost: (
ts: typeof import('typescript/lib/tsserverlibrary'),
capabilities: vscode.ClientCapabilities,
) => FileSystemHost,
}
export type LanguageServerPlugin<
A extends LanguageServerInitializationOptions = LanguageServerInitializationOptions,
B extends embedded.LanguageServiceHost = embedded.LanguageServiceHost,
C = embeddedLS.LanguageService
> = (initOptions: A) => {
extraFileExtensions: ts.FileExtensionInfo[],
semanticService?: {
resolveLanguageServiceHost?(
ts: typeof import('typescript/lib/tsserverlibrary'),
sys: FileSystem,
tsConfig: string | ts.CompilerOptions,
host: embedded.LanguageServiceHost,
): B,
getLanguageModules?(host: B): embedded.LanguageModule[],
getServicePlugins?(
host: B,
service: embeddedLS.LanguageService,
): embeddedLS.LanguageServicePlugin[],
onInitialize?(
connection: vscode.Connection,
getLanguageService: (uri: string) => Promise<C>,
): void,
},
syntacticService?: {
getLanguageModules?(
ts: typeof import('typescript/lib/tsserverlibrary'),
env: embeddedLS.LanguageServicePluginContext['env'],
): embedded.LanguageModule[],
getServicePlugins?(
context: embeddedLS.DocumentServiceRuntimeContext,
): embeddedLS.LanguageServicePlugin[],
onInitialize?(
connection: vscode.Connection,
): void,
};
};
export enum ServerMode {
Semantic = 0,
// PartialSemantic = 1, // not support yet
Syntactic = 2
}
export enum DiagnosticModel {
None = 0,
Push = 1,
Pull = 2,
}
export interface LanguageServerInitializationOptions {
typescript: {
// Absolute path to node_modules/typescript/lib
tsdk: string;
};
serverMode?: ServerMode;
diagnosticModel?: DiagnosticModel;
textDocumentSync?: vscode.TextDocumentSyncKind | number;
// for resolve https://github.com/sublimelsp/LSP-volar/issues/114
ignoreTriggerCharacters?: string[];
/**
* https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29#cancellation
*/
cancellationPipeName?: string;
noProjectReferences?: boolean;
reverseConfigFilePriority?: boolean;
disableFileWatcher?: boolean;
/**
* Enable this option to make language server setup server capabilities based on client capabilities to support multiple servers.
*/
respectClientCapabilities?: boolean;
maxFileSize?: number;
}