-
Notifications
You must be signed in to change notification settings - Fork 281
/
Copy pathyamlSettings.ts
132 lines (122 loc) · 3.95 KB
/
yamlSettings.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
import { TextDocuments, Disposable, ClientCapabilities, WorkspaceFolder } from 'vscode-languageserver';
import { CustomFormatterOptions, SchemaConfiguration } from './languageservice/yamlLanguageService';
import { ISchemaAssociations } from './requestTypes';
import { URI } from 'vscode-uri';
import { JSONSchema } from './languageservice/jsonSchema';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { JSON_SCHEMASTORE_URL } from './languageservice/utils/schemaUrls';
import { YamlVersion } from './languageservice/parser/yamlParser07';
// Client settings interface to grab settings relevant for the language server
export interface Settings {
yaml: {
format: CustomFormatterOptions;
schemas: JSONSchemaSettings[];
validate: boolean;
hover: boolean;
completion: boolean;
customTags: Array<string>;
schemaStore: {
url: string;
enable: boolean;
};
disableDefaultProperties: boolean;
disableAdditionalProperties: boolean;
suggest: {
parentSkeletonSelectedFirst: boolean;
};
style: {
flowMapping: 'allow' | 'forbid';
flowSequence: 'allow' | 'forbid';
};
keyOrdering: boolean;
maxItemsComputed: number;
yamlVersion: YamlVersion;
autoDetectKubernetesSchema: boolean;
};
http: {
proxy: string;
proxyStrictSSL: boolean;
};
yamlEditor: {
'editor.tabSize': number;
'editor.insertSpaces': boolean;
'editor.formatOnType': boolean;
};
vscodeEditor: {
detectIndentation: boolean;
};
files: {
associations: Map<string, string>;
};
}
export interface JSONSchemaSettings {
fileMatch?: string[];
url?: string;
schema?: JSONSchema;
}
// This class is responsible for handling all the settings
export class SettingsState {
yamlConfigurationSettings: JSONSchemaSettings[] = undefined;
schemaAssociations: ISchemaAssociations | SchemaConfiguration[] | undefined = undefined;
formatterRegistration: PromiseLike<Disposable> = null;
specificValidatorPaths = [];
schemaConfigurationSettings = [];
yamlShouldValidate = true;
yamlFormatterSettings = {
singleQuote: false,
bracketSpacing: true,
proseWrap: 'preserve',
printWidth: 80,
enable: true,
} as CustomFormatterOptions;
yamlShouldHover = true;
yamlShouldCompletion = true;
schemaStoreSettings = [];
customTags = [];
schemaStoreEnabled = true;
schemaStoreUrl = JSON_SCHEMASTORE_URL;
indentation: string | undefined = undefined;
disableAdditionalProperties = false;
disableDefaultProperties = false;
suggest = {
parentSkeletonSelectedFirst: false,
};
style: {
flowMapping: 'allow' | 'forbid';
flowSequence: 'allow' | 'forbid';
};
keyOrdering = false;
maxItemsComputed = 5000;
autoDetectKubernetesSchema = false;
// File validation helpers
pendingValidationRequests: { [uri: string]: NodeJS.Timer } = {};
validationDelayMs = 200;
// Create a simple text document manager. The text document manager
// supports full document sync only
documents: TextDocuments<TextDocument> | TextDocumentTestManager = new TextDocuments(TextDocument);
// Language client configuration
capabilities: ClientCapabilities;
workspaceRoot: URI = null;
workspaceFolders: WorkspaceFolder[] = [];
clientDynamicRegisterSupport = false;
hierarchicalDocumentSymbolSupport = false;
hasWorkspaceFolderCapability = false;
hasConfigurationCapability = false;
useVSCodeContentRequest = false;
yamlVersion: YamlVersion = '1.2';
useSchemaSelectionRequests = false;
hasWsChangeWatchedFileDynamicRegistration = false;
fileExtensions: string[] = ['.yml', '.yaml'];
}
export class TextDocumentTestManager extends TextDocuments<TextDocument> {
testTextDocuments = new Map<string, TextDocument>();
constructor() {
super(TextDocument);
}
get(uri: string): TextDocument | undefined {
return this.testTextDocuments.get(uri);
}
set(textDocument: TextDocument): void {
this.testTextDocuments.set(textDocument.uri, textDocument);
}
}