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