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