forked from microsoft/vscode-css-languageservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cssLanguageTypes.ts
316 lines (282 loc) · 8.37 KB
/
cssLanguageTypes.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {
Range, Position, DocumentUri, MarkupContent, MarkupKind,
Color, ColorInformation, ColorPresentation,
FoldingRange, FoldingRangeKind, SelectionRange,
Diagnostic, DiagnosticSeverity,
CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag,
InsertTextFormat, DefinitionLink,
SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString,
CodeActionContext, Command, CodeAction,
DocumentHighlight, DocumentLink, WorkspaceEdit,
TextEdit, CodeActionKind,
TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind
} from 'vscode-languageserver-types';
import { TextDocument } from 'vscode-languageserver-textdocument';
export {
TextDocument,
Range, Position, DocumentUri, MarkupContent, MarkupKind,
Color, ColorInformation, ColorPresentation,
FoldingRange, FoldingRangeKind, SelectionRange,
Diagnostic, DiagnosticSeverity,
CompletionItem, CompletionItemKind, CompletionList, CompletionItemTag,
InsertTextFormat, DefinitionLink,
SymbolInformation, SymbolKind, DocumentSymbol, Location, Hover, MarkedString,
CodeActionContext, Command, CodeAction,
DocumentHighlight, DocumentLink, WorkspaceEdit,
TextEdit, CodeActionKind,
TextDocumentEdit, VersionedTextDocumentIdentifier, DocumentHighlightKind
};
export type LintSettings = { [key: string]: any };
export interface CompletionSettings {
triggerPropertyValueCompletion: boolean;
completePropertyWithSemicolon?: boolean;
}
export interface LanguageSettings {
validate?: boolean;
lint?: LintSettings;
completion?: CompletionSettings;
hover?: HoverSettings;
importAliases?: AliasSettings;
}
export interface AliasSettings {
[key: string]: string;
}
export interface HoverSettings {
documentation?: boolean;
references?: boolean
}
export interface PropertyCompletionContext {
propertyName: string;
range: Range;
}
export interface PropertyValueCompletionContext {
propertyName: string;
propertyValue?: string;
range: Range;
}
export interface URILiteralCompletionContext {
uriValue: string;
position: Position;
range: Range;
}
export interface ImportPathCompletionContext {
pathValue: string;
position: Position;
range: Range;
}
export interface MixinReferenceCompletionContext {
mixinName: string;
range: Range;
}
export interface ICompletionParticipant {
onCssProperty?: (context: PropertyCompletionContext) => void;
onCssPropertyValue?: (context: PropertyValueCompletionContext) => void;
onCssURILiteralValue?: (context: URILiteralCompletionContext) => void;
onCssImportPath?: (context: ImportPathCompletionContext) => void;
onCssMixinReference?: (context: MixinReferenceCompletionContext) => void;
}
export interface DocumentContext {
resolveReference(ref: string, baseUrl: string): string | undefined;
}
/**
* Describes what LSP capabilities the client supports
*/
export interface ClientCapabilities {
/**
* The text document client capabilities
*/
textDocument?: {
/**
* Capabilities specific to completions.
*/
completion?: {
/**
* The client supports the following `CompletionItem` specific
* capabilities.
*/
completionItem?: {
/**
* Client supports the follow content formats for the documentation
* property. The order describes the preferred format of the client.
*/
documentationFormat?: MarkupKind[];
};
};
/**
* Capabilities specific to hovers.
*/
hover?: {
/**
* Client supports the follow content formats for the content
* property. The order describes the preferred format of the client.
*/
contentFormat?: MarkupKind[];
};
};
}
export namespace ClientCapabilities {
export const LATEST: ClientCapabilities = {
textDocument: {
completion: {
completionItem: {
documentationFormat: [MarkupKind.Markdown, MarkupKind.PlainText]
}
},
hover: {
contentFormat: [MarkupKind.Markdown, MarkupKind.PlainText]
}
}
};
}
export interface LanguageServiceOptions {
/**
* Unless set to false, the default CSS data provider will be used
* along with the providers from customDataProviders.
* Defaults to true.
*/
useDefaultDataProvider?: boolean;
/**
* Provide data that could enhance the service's understanding of
* CSS property / at-rule / pseudo-class / pseudo-element
*/
customDataProviders?: ICSSDataProvider[];
/**
* Abstract file system access away from the service.
* Used for dynamic link resolving, path completion, etc.
*/
fileSystemProvider?: FileSystemProvider;
/**
* Describes the LSP capabilities the client supports.
*/
clientCapabilities?: ClientCapabilities;
}
export type EntryStatus = 'standard' | 'experimental' | 'nonstandard' | 'obsolete';
export interface IReference {
name: string;
url: string;
}
export interface IPropertyData {
name: string;
description?: string | MarkupContent;
browsers?: string[];
restrictions?: string[];
status?: EntryStatus;
syntax?: string;
values?: IValueData[];
references?: IReference[];
relevance?: number;
atRule?: string;
}
export interface IAtDirectiveData {
name: string;
description?: string | MarkupContent;
browsers?: string[];
status?: EntryStatus;
references?: IReference[];
}
export interface IPseudoClassData {
name: string;
description?: string | MarkupContent;
browsers?: string[];
status?: EntryStatus;
references?: IReference[];
}
export interface IPseudoElementData {
name: string;
description?: string | MarkupContent;
browsers?: string[];
status?: EntryStatus;
references?: IReference[];
}
export interface IValueData {
name: string;
description?: string | MarkupContent;
browsers?: string[];
status?: EntryStatus;
references?: IReference[];
}
export interface CSSDataV1 {
version: 1 | 1.1;
properties?: IPropertyData[];
atDirectives?: IAtDirectiveData[];
pseudoClasses?: IPseudoClassData[];
pseudoElements?: IPseudoElementData[];
}
export interface ICSSDataProvider {
provideProperties(): IPropertyData[];
provideAtDirectives(): IAtDirectiveData[];
providePseudoClasses(): IPseudoClassData[];
providePseudoElements(): IPseudoElementData[];
}
export enum FileType {
/**
* The file type is unknown.
*/
Unknown = 0,
/**
* A regular file.
*/
File = 1,
/**
* A directory.
*/
Directory = 2,
/**
* A symbolic link to a file.
*/
SymbolicLink = 64
}
export interface FileStat {
/**
* The type of the file, e.g. is a regular file, a directory, or symbolic link
* to a file.
*/
type: FileType;
/**
* The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
ctime: number;
/**
* The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
mtime: number;
/**
* The size in bytes.
*/
size: number;
}
export interface FileSystemProvider {
stat(uri: DocumentUri): Promise<FileStat>;
readDirectory?(uri: DocumentUri): Promise<[string, FileType][]>;
}
export interface CSSFormatConfiguration {
/** indentation size. Default: 4 */
tabSize?: number;
/** Whether to use spaces or tabs */
insertSpaces?: boolean;
/** end with a newline: Default: false */
insertFinalNewline?: boolean;
/** separate selectors with newline (e.g. "a,\nbr" or "a, br"): Default: true */
newlineBetweenSelectors?: boolean;
/** add a new line after every css rule: Default: true */
newlineBetweenRules?: boolean;
/** ensure space around selector separators: '>', '+', '~' (e.g. "a>b" -> "a > b"): Default: false */
spaceAroundSelectorSeparator?: boolean;
/** put braces on the same line as rules (`collapse`), or put braces on own line, Allman / ANSI style (`expand`). Default `collapse` */
braceStyle?: 'collapse' | 'expand';
/** whether existing line breaks before elements should be preserved. Default: true */
preserveNewLines?: boolean;
/** maximum number of line breaks to be preserved in one chunk. Default: unlimited */
maxPreserveNewLines?: number;
/** maximum amount of characters per line (0/undefined = disabled). Default: disabled. */
wrapLineLength?: number;
/** add indenting whitespace to empty lines. Default: false */
indentEmptyLines?: boolean;
/** @deprecated Use newlineBetweenSelectors instead*/
selectorSeparatorNewline?: boolean;
}