Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/common/config/editorConfigurationSchema.ts
5253 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import type { IJSONSchemaSnippet } from '../../../base/common/jsonSchema.js';
7
import { diffEditorDefaultOptions } from './diffEditor.js';
8
import { editorOptionsRegistry } from './editorOptions.js';
9
import { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';
10
import * as nls from '../../../nls.js';
11
import { ConfigurationScope, Extensions, IConfigurationNode, IConfigurationPropertySchema, IConfigurationRegistry } from '../../../platform/configuration/common/configurationRegistry.js';
12
import { Registry } from '../../../platform/registry/common/platform.js';
13
14
export const editorConfigurationBaseNode = Object.freeze<IConfigurationNode>({
15
id: 'editor',
16
order: 5,
17
type: 'object',
18
title: nls.localize('editorConfigurationTitle', "Editor"),
19
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
20
});
21
22
const editorConfiguration: IConfigurationNode = {
23
...editorConfigurationBaseNode,
24
properties: {
25
'editor.tabSize': {
26
type: 'number',
27
default: EDITOR_MODEL_DEFAULTS.tabSize,
28
minimum: 1,
29
maximum: 100,
30
markdownDescription: nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when {0} is on.", '`#editor.detectIndentation#`')
31
},
32
'editor.indentSize': {
33
'anyOf': [
34
{
35
type: 'string',
36
enum: ['tabSize']
37
},
38
{
39
type: 'number',
40
minimum: 1
41
}
42
],
43
default: 'tabSize',
44
markdownDescription: nls.localize('indentSize', "The number of spaces used for indentation or `\"tabSize\"` to use the value from `#editor.tabSize#`. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on.")
45
},
46
'editor.insertSpaces': {
47
type: 'boolean',
48
default: EDITOR_MODEL_DEFAULTS.insertSpaces,
49
markdownDescription: nls.localize('insertSpaces', "Insert spaces when pressing `Tab`. This setting is overridden based on the file contents when {0} is on.", '`#editor.detectIndentation#`')
50
},
51
'editor.detectIndentation': {
52
type: 'boolean',
53
default: EDITOR_MODEL_DEFAULTS.detectIndentation,
54
markdownDescription: nls.localize('detectIndentation', "Controls whether {0} and {1} will be automatically detected when a file is opened based on the file contents.", '`#editor.tabSize#`', '`#editor.insertSpaces#`')
55
},
56
'editor.trimAutoWhitespace': {
57
type: 'boolean',
58
default: EDITOR_MODEL_DEFAULTS.trimAutoWhitespace,
59
description: nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace.")
60
},
61
'editor.largeFileOptimizations': {
62
type: 'boolean',
63
default: EDITOR_MODEL_DEFAULTS.largeFileOptimizations,
64
description: nls.localize('largeFileOptimizations', "Special handling for large files to disable certain memory intensive features.")
65
},
66
'editor.wordBasedSuggestions': {
67
enum: ['off', 'offWithInlineSuggestions', 'currentDocument', 'matchingDocuments', 'allDocuments'],
68
default: 'offWithInlineSuggestions',
69
enumDescriptions: [
70
nls.localize('wordBasedSuggestions.off', 'Turn off Word Based Suggestions.'),
71
nls.localize('wordBasedSuggestions.offWithInlineSuggestions', 'Turn off Word Based Suggestions when Inline Suggestions are present.'),
72
nls.localize('wordBasedSuggestions.currentDocument', 'Only suggest words from the active document.'),
73
nls.localize('wordBasedSuggestions.matchingDocuments', 'Suggest words from all open documents of the same language.'),
74
nls.localize('wordBasedSuggestions.allDocuments', 'Suggest words from all open documents.'),
75
],
76
description: nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document and from which documents they are computed."),
77
experiment: { mode: 'auto' },
78
},
79
'editor.semanticHighlighting.enabled': {
80
enum: [true, false, 'configuredByTheme'],
81
enumDescriptions: [
82
nls.localize('semanticHighlighting.true', 'Semantic highlighting enabled for all color themes.'),
83
nls.localize('semanticHighlighting.false', 'Semantic highlighting disabled for all color themes.'),
84
nls.localize('semanticHighlighting.configuredByTheme', 'Semantic highlighting is configured by the current color theme\'s `semanticHighlighting` setting.')
85
],
86
default: 'configuredByTheme',
87
description: nls.localize('semanticHighlighting.enabled', "Controls whether the semanticHighlighting is shown for the languages that support it.")
88
},
89
'editor.stablePeek': {
90
type: 'boolean',
91
default: false,
92
markdownDescription: nls.localize('stablePeek', "Keep peek editors open even when double-clicking their content or when hitting `Escape`.")
93
},
94
'editor.maxTokenizationLineLength': {
95
type: 'integer',
96
default: 20_000,
97
description: nls.localize('maxTokenizationLineLength', "Lines above this length will not be tokenized for performance reasons")
98
},
99
'editor.experimental.asyncTokenization': {
100
type: 'boolean',
101
default: true,
102
description: nls.localize('editor.experimental.asyncTokenization', "Controls whether the tokenization should happen asynchronously on a web worker."),
103
tags: ['experimental'],
104
},
105
'editor.experimental.asyncTokenizationLogging': {
106
type: 'boolean',
107
default: false,
108
description: nls.localize('editor.experimental.asyncTokenizationLogging', "Controls whether async tokenization should be logged. For debugging only."),
109
},
110
'editor.experimental.asyncTokenizationVerification': {
111
type: 'boolean',
112
default: false,
113
description: nls.localize('editor.experimental.asyncTokenizationVerification', "Controls whether async tokenization should be verified against legacy background tokenization. Might slow down tokenization. For debugging only."),
114
tags: ['experimental'],
115
},
116
'editor.experimental.treeSitterTelemetry': {
117
type: 'boolean',
118
default: false,
119
markdownDescription: nls.localize('editor.experimental.treeSitterTelemetry', "Controls whether tree sitter parsing should be turned on and telemetry collected. Setting `#editor.experimental.preferTreeSitter#` for specific languages will take precedence."),
120
tags: ['experimental'],
121
experiment: {
122
mode: 'auto'
123
}
124
},
125
'editor.experimental.preferTreeSitter.css': {
126
type: 'boolean',
127
default: false,
128
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.css', "Controls whether tree sitter parsing should be turned on for css. This will take precedence over `#editor.experimental.treeSitterTelemetry#` for css."),
129
tags: ['experimental'],
130
experiment: {
131
mode: 'auto'
132
}
133
},
134
'editor.experimental.preferTreeSitter.typescript': {
135
type: 'boolean',
136
default: false,
137
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.typescript', "Controls whether tree sitter parsing should be turned on for typescript. This will take precedence over `#editor.experimental.treeSitterTelemetry#` for typescript."),
138
tags: ['experimental'],
139
experiment: {
140
mode: 'auto'
141
}
142
},
143
'editor.experimental.preferTreeSitter.ini': {
144
type: 'boolean',
145
default: false,
146
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.ini', "Controls whether tree sitter parsing should be turned on for ini. This will take precedence over `#editor.experimental.treeSitterTelemetry#` for ini."),
147
tags: ['experimental'],
148
experiment: {
149
mode: 'auto'
150
}
151
},
152
'editor.experimental.preferTreeSitter.regex': {
153
type: 'boolean',
154
default: false,
155
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.regex', "Controls whether tree sitter parsing should be turned on for regex. This will take precedence over `#editor.experimental.treeSitterTelemetry#` for regex."),
156
tags: ['experimental'],
157
experiment: {
158
mode: 'auto'
159
}
160
},
161
'editor.language.brackets': {
162
type: ['array', 'null'],
163
default: null, // We want to distinguish the empty array from not configured.
164
description: nls.localize('schema.brackets', 'Defines the bracket symbols that increase or decrease the indentation.'),
165
items: {
166
type: 'array',
167
items: [
168
{
169
type: 'string',
170
description: nls.localize('schema.openBracket', 'The opening bracket character or string sequence.')
171
},
172
{
173
type: 'string',
174
description: nls.localize('schema.closeBracket', 'The closing bracket character or string sequence.')
175
}
176
]
177
}
178
},
179
'editor.language.colorizedBracketPairs': {
180
type: ['array', 'null'],
181
default: null, // We want to distinguish the empty array from not configured.
182
description: nls.localize('schema.colorizedBracketPairs', 'Defines the bracket pairs that are colorized by their nesting level if bracket pair colorization is enabled.'),
183
items: {
184
type: 'array',
185
items: [
186
{
187
type: 'string',
188
description: nls.localize('schema.openBracket', 'The opening bracket character or string sequence.')
189
},
190
{
191
type: 'string',
192
description: nls.localize('schema.closeBracket', 'The closing bracket character or string sequence.')
193
}
194
]
195
}
196
},
197
'diffEditor.maxComputationTime': {
198
type: 'number',
199
default: diffEditorDefaultOptions.maxComputationTime,
200
description: nls.localize('maxComputationTime', "Timeout in milliseconds after which diff computation is cancelled. Use 0 for no timeout.")
201
},
202
'diffEditor.maxFileSize': {
203
type: 'number',
204
default: diffEditorDefaultOptions.maxFileSize,
205
description: nls.localize('maxFileSize', "Maximum file size in MB for which to compute diffs. Use 0 for no limit.")
206
},
207
'diffEditor.renderSideBySide': {
208
type: 'boolean',
209
default: diffEditorDefaultOptions.renderSideBySide,
210
description: nls.localize('sideBySide', "Controls whether the diff editor shows the diff side by side or inline.")
211
},
212
'diffEditor.renderSideBySideInlineBreakpoint': {
213
type: 'number',
214
default: diffEditorDefaultOptions.renderSideBySideInlineBreakpoint,
215
description: nls.localize('renderSideBySideInlineBreakpoint', "If the diff editor width is smaller than this value, the inline view is used.")
216
},
217
'diffEditor.useInlineViewWhenSpaceIsLimited': {
218
type: 'boolean',
219
default: diffEditorDefaultOptions.useInlineViewWhenSpaceIsLimited,
220
description: nls.localize('useInlineViewWhenSpaceIsLimited', "If enabled and the editor width is too small, the inline view is used.")
221
},
222
'diffEditor.renderMarginRevertIcon': {
223
type: 'boolean',
224
default: diffEditorDefaultOptions.renderMarginRevertIcon,
225
description: nls.localize('renderMarginRevertIcon', "When enabled, the diff editor shows arrows in its glyph margin to revert changes.")
226
},
227
'diffEditor.renderGutterMenu': {
228
type: 'boolean',
229
default: diffEditorDefaultOptions.renderGutterMenu,
230
description: nls.localize('renderGutterMenu', "When enabled, the diff editor shows a special gutter for revert and stage actions.")
231
},
232
'diffEditor.ignoreTrimWhitespace': {
233
type: 'boolean',
234
default: diffEditorDefaultOptions.ignoreTrimWhitespace,
235
description: nls.localize('ignoreTrimWhitespace', "When enabled, the diff editor ignores changes in leading or trailing whitespace.")
236
},
237
'diffEditor.renderIndicators': {
238
type: 'boolean',
239
default: diffEditorDefaultOptions.renderIndicators,
240
description: nls.localize('renderIndicators', "Controls whether the diff editor shows +/- indicators for added/removed changes.")
241
},
242
'diffEditor.codeLens': {
243
type: 'boolean',
244
default: diffEditorDefaultOptions.diffCodeLens,
245
description: nls.localize('codeLens', "Controls whether the editor shows CodeLens.")
246
},
247
'diffEditor.wordWrap': {
248
type: 'string',
249
enum: ['off', 'on', 'inherit'],
250
default: diffEditorDefaultOptions.diffWordWrap,
251
markdownEnumDescriptions: [
252
nls.localize('wordWrap.off', "Lines will never wrap."),
253
nls.localize('wordWrap.on', "Lines will wrap at the viewport width."),
254
nls.localize('wordWrap.inherit', "Lines will wrap according to the {0} setting.", '`#editor.wordWrap#`'),
255
]
256
},
257
'diffEditor.diffAlgorithm': {
258
type: 'string',
259
enum: ['legacy', 'advanced'],
260
default: diffEditorDefaultOptions.diffAlgorithm,
261
markdownEnumDescriptions: [
262
nls.localize('diffAlgorithm.legacy', "Uses the legacy diffing algorithm."),
263
nls.localize('diffAlgorithm.advanced', "Uses the advanced diffing algorithm."),
264
]
265
},
266
'diffEditor.hideUnchangedRegions.enabled': {
267
type: 'boolean',
268
default: diffEditorDefaultOptions.hideUnchangedRegions.enabled,
269
markdownDescription: nls.localize('hideUnchangedRegions.enabled', "Controls whether the diff editor shows unchanged regions."),
270
},
271
'diffEditor.hideUnchangedRegions.revealLineCount': {
272
type: 'integer',
273
default: diffEditorDefaultOptions.hideUnchangedRegions.revealLineCount,
274
markdownDescription: nls.localize('hideUnchangedRegions.revealLineCount', "Controls how many lines are used for unchanged regions."),
275
minimum: 1,
276
},
277
'diffEditor.hideUnchangedRegions.minimumLineCount': {
278
type: 'integer',
279
default: diffEditorDefaultOptions.hideUnchangedRegions.minimumLineCount,
280
markdownDescription: nls.localize('hideUnchangedRegions.minimumLineCount', "Controls how many lines are used as a minimum for unchanged regions."),
281
minimum: 1,
282
},
283
'diffEditor.hideUnchangedRegions.contextLineCount': {
284
type: 'integer',
285
default: diffEditorDefaultOptions.hideUnchangedRegions.contextLineCount,
286
markdownDescription: nls.localize('hideUnchangedRegions.contextLineCount', "Controls how many lines are used as context when comparing unchanged regions."),
287
minimum: 1,
288
},
289
'diffEditor.experimental.showMoves': {
290
type: 'boolean',
291
default: diffEditorDefaultOptions.experimental.showMoves,
292
markdownDescription: nls.localize('showMoves', "Controls whether the diff editor should show detected code moves.")
293
},
294
'diffEditor.experimental.showEmptyDecorations': {
295
type: 'boolean',
296
default: diffEditorDefaultOptions.experimental.showEmptyDecorations,
297
description: nls.localize('showEmptyDecorations', "Controls whether the diff editor shows empty decorations to see where characters got inserted or deleted."),
298
},
299
'diffEditor.experimental.useTrueInlineView': {
300
type: 'boolean',
301
default: diffEditorDefaultOptions.experimental.useTrueInlineView,
302
description: nls.localize('useTrueInlineView', "If enabled and the editor uses the inline view, word changes are rendered inline."),
303
},
304
}
305
};
306
307
function isConfigurationPropertySchema(x: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema }): x is IConfigurationPropertySchema {
308
return (typeof x.type !== 'undefined' || typeof x.anyOf !== 'undefined');
309
}
310
311
// Add properties from the Editor Option Registry
312
for (const editorOption of editorOptionsRegistry) {
313
const schema = editorOption.schema;
314
if (typeof schema !== 'undefined') {
315
if (isConfigurationPropertySchema(schema)) {
316
// This is a single schema contribution
317
editorConfiguration.properties![`editor.${editorOption.name}`] = schema;
318
} else {
319
for (const key in schema) {
320
if (Object.hasOwnProperty.call(schema, key)) {
321
editorConfiguration.properties![key] = schema[key];
322
}
323
}
324
}
325
}
326
}
327
328
let cachedEditorConfigurationKeys: { [key: string]: boolean } | null = null;
329
function getEditorConfigurationKeys(): { [key: string]: boolean } {
330
if (cachedEditorConfigurationKeys === null) {
331
cachedEditorConfigurationKeys = <{ [key: string]: boolean }>Object.create(null);
332
Object.keys(editorConfiguration.properties!).forEach((prop) => {
333
cachedEditorConfigurationKeys![prop] = true;
334
});
335
}
336
return cachedEditorConfigurationKeys;
337
}
338
339
export function isEditorConfigurationKey(key: string): boolean {
340
const editorConfigurationKeys = getEditorConfigurationKeys();
341
return (editorConfigurationKeys[`editor.${key}`] || false);
342
}
343
344
export function isDiffEditorConfigurationKey(key: string): boolean {
345
const editorConfigurationKeys = getEditorConfigurationKeys();
346
return (editorConfigurationKeys[`diffEditor.${key}`] || false);
347
}
348
349
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
350
configurationRegistry.registerConfiguration(editorConfiguration);
351
352
export async function registerEditorFontConfigurations(getFontSnippets: () => Promise<IJSONSchemaSnippet[]>) {
353
const editorKeysWithFont = ['editor.fontFamily'];
354
const fontSnippets = await getFontSnippets();
355
for (const key of editorKeysWithFont) {
356
if (
357
editorConfiguration.properties && editorConfiguration.properties[key]
358
) {
359
editorConfiguration.properties[key].defaultSnippets = fontSnippets;
360
}
361
}
362
}
363
364