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