mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-14 23:18:36 +00:00
@@ -798,6 +798,26 @@
|
||||
"title": "%configuration.preferences%",
|
||||
"order": 21,
|
||||
"properties": {
|
||||
"js/ts.preferences.quoteStyle": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"single",
|
||||
"double"
|
||||
],
|
||||
"default": "auto",
|
||||
"markdownDescription": "%typescript.preferences.quoteStyle%",
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.quoteStyle.auto%",
|
||||
"%typescript.preferences.quoteStyle.single%",
|
||||
"%typescript.preferences.quoteStyle.double%"
|
||||
],
|
||||
"scope": "language-overridable",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.quoteStyle": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -812,6 +832,7 @@
|
||||
"%typescript.preferences.quoteStyle.single%",
|
||||
"%typescript.preferences.quoteStyle.double%"
|
||||
],
|
||||
"markdownDeprecationMessage": "%configuration.preferences.quoteStyle.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"typescript.preferences.quoteStyle": {
|
||||
@@ -828,8 +849,31 @@
|
||||
"%typescript.preferences.quoteStyle.single%",
|
||||
"%typescript.preferences.quoteStyle.double%"
|
||||
],
|
||||
"markdownDeprecationMessage": "%configuration.preferences.quoteStyle.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"js/ts.preferences.importModuleSpecifier": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"shortest",
|
||||
"relative",
|
||||
"non-relative",
|
||||
"project-relative"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.importModuleSpecifier.shortest%",
|
||||
"%typescript.preferences.importModuleSpecifier.relative%",
|
||||
"%typescript.preferences.importModuleSpecifier.nonRelative%",
|
||||
"%typescript.preferences.importModuleSpecifier.projectRelative%"
|
||||
],
|
||||
"default": "shortest",
|
||||
"description": "%typescript.preferences.importModuleSpecifier%",
|
||||
"scope": "language-overridable",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.importModuleSpecifier": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -846,6 +890,7 @@
|
||||
],
|
||||
"default": "shortest",
|
||||
"description": "%typescript.preferences.importModuleSpecifier%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.importModuleSpecifier.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"typescript.preferences.importModuleSpecifier": {
|
||||
@@ -864,8 +909,37 @@
|
||||
],
|
||||
"default": "shortest",
|
||||
"description": "%typescript.preferences.importModuleSpecifier%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.importModuleSpecifier.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"js/ts.preferences.importModuleSpecifierEnding": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"minimal",
|
||||
"index",
|
||||
"js"
|
||||
],
|
||||
"enumItemLabels": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"%typescript.preferences.importModuleSpecifierEnding.label.js%"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.importModuleSpecifierEnding.auto%",
|
||||
"%typescript.preferences.importModuleSpecifierEnding.minimal%",
|
||||
"%typescript.preferences.importModuleSpecifierEnding.index%",
|
||||
"%typescript.preferences.importModuleSpecifierEnding.js%"
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "%typescript.preferences.importModuleSpecifierEnding%",
|
||||
"scope": "language-overridable",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.importModuleSpecifierEnding": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -888,6 +962,7 @@
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "%typescript.preferences.importModuleSpecifierEnding%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.importModuleSpecifierEnding.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"typescript.preferences.importModuleSpecifierEnding": {
|
||||
@@ -912,8 +987,29 @@
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "%typescript.preferences.importModuleSpecifierEnding%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.importModuleSpecifierEnding.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"js/ts.preferences.jsxAttributeCompletionStyle": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"braces",
|
||||
"none"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%configuration.preferences.jsxAttributeCompletionStyle.auto%",
|
||||
"%typescript.preferences.jsxAttributeCompletionStyle.braces%",
|
||||
"%typescript.preferences.jsxAttributeCompletionStyle.none%"
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "%typescript.preferences.jsxAttributeCompletionStyle%",
|
||||
"scope": "language-overridable",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.jsxAttributeCompletionStyle": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -928,6 +1024,7 @@
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "%typescript.preferences.jsxAttributeCompletionStyle%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.jsxAttributeCompletionStyle.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"typescript.preferences.jsxAttributeCompletionStyle": {
|
||||
@@ -944,8 +1041,28 @@
|
||||
],
|
||||
"default": "auto",
|
||||
"description": "%typescript.preferences.jsxAttributeCompletionStyle%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.jsxAttributeCompletionStyle.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"js/ts.preferences.includePackageJsonAutoImports": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"auto",
|
||||
"on",
|
||||
"off"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"%typescript.preferences.includePackageJsonAutoImports.auto%",
|
||||
"%typescript.preferences.includePackageJsonAutoImports.on%",
|
||||
"%typescript.preferences.includePackageJsonAutoImports.off%"
|
||||
],
|
||||
"default": "auto",
|
||||
"markdownDescription": "%typescript.preferences.includePackageJsonAutoImports%",
|
||||
"scope": "window",
|
||||
"tags": [
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"typescript.preferences.includePackageJsonAutoImports": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -960,14 +1077,28 @@
|
||||
],
|
||||
"default": "auto",
|
||||
"markdownDescription": "%typescript.preferences.includePackageJsonAutoImports%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.includePackageJsonAutoImports.unifiedDeprecationMessage%",
|
||||
"scope": "window"
|
||||
},
|
||||
"js/ts.preferences.autoImportFileExcludePatterns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportFileExcludePatterns%",
|
||||
"scope": "resource",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.autoImportFileExcludePatterns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportFileExcludePatterns%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.autoImportFileExcludePatterns.unifiedDeprecationMessage%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"typescript.preferences.autoImportFileExcludePatterns": {
|
||||
@@ -976,14 +1107,28 @@
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportFileExcludePatterns%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.autoImportFileExcludePatterns.unifiedDeprecationMessage%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"js/ts.preferences.autoImportSpecifierExcludeRegexes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportSpecifierExcludeRegexes%",
|
||||
"scope": "resource",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.autoImportSpecifierExcludeRegexes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportSpecifierExcludeRegexes%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.autoImportSpecifierExcludeRegexes.unifiedDeprecationMessage%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"typescript.preferences.autoImportSpecifierExcludeRegexes": {
|
||||
@@ -992,41 +1137,159 @@
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportSpecifierExcludeRegexes%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.autoImportSpecifierExcludeRegexes.unifiedDeprecationMessage%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"js/ts.preferences.preferTypeOnlyAutoImports": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"markdownDescription": "%typescript.preferences.preferTypeOnlyAutoImports%",
|
||||
"scope": "resource",
|
||||
"tags": [
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"typescript.preferences.preferTypeOnlyAutoImports": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"markdownDescription": "%typescript.preferences.preferTypeOnlyAutoImports%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.preferTypeOnlyAutoImports.unifiedDeprecationMessage%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"js/ts.preferences.useAliasesForRenames": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%typescript.preferences.useAliasesForRenames%",
|
||||
"scope": "language-overridable",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.useAliasesForRenames": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%typescript.preferences.useAliasesForRenames%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.useAliasesForRenames.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"typescript.preferences.useAliasesForRenames": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%typescript.preferences.useAliasesForRenames%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.useAliasesForRenames.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"js/ts.preferences.renameMatchingJsxTags": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%typescript.preferences.renameMatchingJsxTags%",
|
||||
"scope": "language-overridable",
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.renameMatchingJsxTags": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%typescript.preferences.renameMatchingJsxTags%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.renameMatchingJsxTags.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"typescript.preferences.renameMatchingJsxTags": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%typescript.preferences.renameMatchingJsxTags%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.renameMatchingJsxTags.unifiedDeprecationMessage%",
|
||||
"scope": "language-overridable"
|
||||
},
|
||||
"js/ts.preferences.organizeImports": {
|
||||
"type": "object",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports%",
|
||||
"properties": {
|
||||
"caseSensitivity": {
|
||||
"type": "string",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.caseSensitivity%",
|
||||
"enum": [
|
||||
"auto",
|
||||
"caseInsensitive",
|
||||
"caseSensitive"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.organizeImports.caseSensitivity.auto%",
|
||||
"%typescript.preferences.organizeImports.caseSensitivity.insensitive",
|
||||
"%typescript.preferences.organizeImports.caseSensitivity.sensitive%"
|
||||
],
|
||||
"default": "auto"
|
||||
},
|
||||
"typeOrder": {
|
||||
"type": "string",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.typeOrder%",
|
||||
"enum": [
|
||||
"auto",
|
||||
"last",
|
||||
"inline",
|
||||
"first"
|
||||
],
|
||||
"default": "auto",
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.organizeImports.typeOrder.auto%",
|
||||
"%typescript.preferences.organizeImports.typeOrder.last%",
|
||||
"%typescript.preferences.organizeImports.typeOrder.inline%",
|
||||
"%typescript.preferences.organizeImports.typeOrder.first%"
|
||||
]
|
||||
},
|
||||
"unicodeCollation": {
|
||||
"type": "string",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.unicodeCollation%",
|
||||
"enum": [
|
||||
"ordinal",
|
||||
"unicode"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.organizeImports.unicodeCollation.ordinal%",
|
||||
"%typescript.preferences.organizeImports.unicodeCollation.unicode%"
|
||||
],
|
||||
"default": "ordinal"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.locale%"
|
||||
},
|
||||
"numericCollation": {
|
||||
"type": "boolean",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.numericCollation%"
|
||||
},
|
||||
"accentCollation": {
|
||||
"type": "boolean",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.accentCollation%"
|
||||
},
|
||||
"caseFirst": {
|
||||
"type": "string",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports.caseFirst%",
|
||||
"enum": [
|
||||
"default",
|
||||
"upper",
|
||||
"lower"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"%typescript.preferences.organizeImports.caseFirst.default%",
|
||||
"%typescript.preferences.organizeImports.caseFirst.upper%",
|
||||
"%typescript.preferences.organizeImports.caseFirst.lower%"
|
||||
],
|
||||
"default": "default"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
]
|
||||
},
|
||||
"javascript.preferences.organizeImports": {
|
||||
"type": "object",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.organizeImports.unifiedDeprecationMessage%",
|
||||
"properties": {
|
||||
"caseSensitivity": {
|
||||
"type": "string",
|
||||
@@ -1105,6 +1368,7 @@
|
||||
"typescript.preferences.organizeImports": {
|
||||
"type": "object",
|
||||
"markdownDescription": "%typescript.preferences.organizeImports%",
|
||||
"markdownDeprecationMessage": "%configuration.preferences.organizeImports.unifiedDeprecationMessage%",
|
||||
"properties": {
|
||||
"caseSensitivity": {
|
||||
"type": "string",
|
||||
|
||||
@@ -155,6 +155,18 @@
|
||||
"typescript.suggestionActions.enabled": "Enable/disable suggestion diagnostics for TypeScript files in the editor.",
|
||||
"configuration.suggestionActions.enabled": "Enable/disable suggestion diagnostics for JavaScript and TypeScript files in the editor.",
|
||||
"configuration.suggestionActions.enabled.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.suggestionActions.enabled#` instead.",
|
||||
"configuration.preferences.quoteStyle.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.quoteStyle#` instead.",
|
||||
"configuration.preferences.importModuleSpecifier.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.importModuleSpecifier#` instead.",
|
||||
"configuration.preferences.importModuleSpecifierEnding.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.importModuleSpecifierEnding#` instead.",
|
||||
"configuration.preferences.jsxAttributeCompletionStyle.auto": "Insert `={}` or `=\"\"` after attribute names based on the prop type. See `#js/ts.preferences.quoteStyle#` to control the type of quotes used for string attributes.",
|
||||
"configuration.preferences.jsxAttributeCompletionStyle.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.jsxAttributeCompletionStyle#` instead.",
|
||||
"configuration.preferences.includePackageJsonAutoImports.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.includePackageJsonAutoImports#` instead.",
|
||||
"configuration.preferences.autoImportFileExcludePatterns.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.autoImportFileExcludePatterns#` instead.",
|
||||
"configuration.preferences.autoImportSpecifierExcludeRegexes.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.autoImportSpecifierExcludeRegexes#` instead.",
|
||||
"configuration.preferences.preferTypeOnlyAutoImports.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.preferTypeOnlyAutoImports#` instead.",
|
||||
"configuration.preferences.useAliasesForRenames.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.useAliasesForRenames#` instead.",
|
||||
"configuration.preferences.renameMatchingJsxTags.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.renameMatchingJsxTags#` instead.",
|
||||
"configuration.preferences.organizeImports.unifiedDeprecationMessage": "This setting is deprecated. Use `#js/ts.preferences.organizeImports#` instead.",
|
||||
"typescript.preferences.quoteStyle": "Preferred quote style to use for Quick Fixes.",
|
||||
"typescript.preferences.quoteStyle.single": "Always use single quotes: `'`",
|
||||
"typescript.preferences.quoteStyle.double": "Always use double quotes: `\"`",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../tsServer/protocol/protocol';
|
||||
import { readUnifiedConfig } from '../utils/configuration';
|
||||
import * as objects from '../utils/objects';
|
||||
|
||||
export enum TsServerLogLevel {
|
||||
@@ -268,8 +269,8 @@ export abstract class BaseServiceConfigurationProvider implements ServiceConfigu
|
||||
return { ...(watchOptions ?? {}) };
|
||||
}
|
||||
|
||||
protected readIncludePackageJsonAutoImports(configuration: vscode.WorkspaceConfiguration): 'auto' | 'on' | 'off' | undefined {
|
||||
return configuration.get<'auto' | 'on' | 'off'>('typescript.preferences.includePackageJsonAutoImports');
|
||||
protected readIncludePackageJsonAutoImports(_configuration: vscode.WorkspaceConfiguration): 'auto' | 'on' | 'off' | undefined {
|
||||
return readUnifiedConfig<'auto' | 'on' | 'off' | undefined>('preferences.includePackageJsonAutoImports', undefined, { fallbackSection: 'typescript' });
|
||||
}
|
||||
|
||||
protected readMaxTsServerMemory(configuration: vscode.WorkspaceConfiguration): number {
|
||||
|
||||
@@ -178,20 +178,16 @@ export default class FileConfigurationManager extends Disposable {
|
||||
isTypeScriptDocument(document) ? 'typescript' : 'javascript',
|
||||
document);
|
||||
|
||||
const preferencesConfig = vscode.workspace.getConfiguration(
|
||||
isTypeScriptDocument(document) ? 'typescript.preferences' : 'javascript.preferences',
|
||||
document);
|
||||
|
||||
const fallbackSection = isTypeScriptDocument(document) ? 'typescript' : 'javascript';
|
||||
|
||||
const preferences: Proto.UserPreferences = {
|
||||
...config.get('unstable'),
|
||||
quotePreference: this.getQuoteStylePreference(preferencesConfig),
|
||||
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
|
||||
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
|
||||
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig),
|
||||
quotePreference: getQuoteStylePreference(document, fallbackSection),
|
||||
importModuleSpecifierPreference: getImportModuleSpecifierPreference(document, fallbackSection),
|
||||
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(document, fallbackSection),
|
||||
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(document, fallbackSection),
|
||||
allowTextChangesInNewFiles: document.uri.scheme === fileSchemes.file,
|
||||
providePrefixAndSuffixTextForRename: preferencesConfig.get<boolean>('useAliasesForRenames', true),
|
||||
providePrefixAndSuffixTextForRename: readUnifiedConfig<boolean>('preferences.useAliasesForRenames', true, { scope: document, fallbackSection }),
|
||||
allowRenameOfImportPath: true,
|
||||
includeAutomaticOptionalChainCompletions: readUnifiedConfig<boolean>('suggest.includeAutomaticOptionalChainCompletions', true, { scope: document, fallbackSection }),
|
||||
provideRefactorNotApplicableReason: true,
|
||||
@@ -200,9 +196,9 @@ export default class FileConfigurationManager extends Disposable {
|
||||
includeCompletionsWithSnippetText: true,
|
||||
includeCompletionsWithClassMemberSnippets: readUnifiedConfig<boolean>('suggest.classMemberSnippets.enabled', true, { scope: document, fallbackSection }),
|
||||
includeCompletionsWithObjectLiteralMethodSnippets: readUnifiedConfig<boolean>('suggest.objectLiteralMethodSnippets.enabled', true, { scope: document, fallbackSection }),
|
||||
autoImportFileExcludePatterns: this.getAutoImportFileExcludePatternsPreference(preferencesConfig, vscode.workspace.getWorkspaceFolder(document.uri)?.uri),
|
||||
autoImportSpecifierExcludeRegexes: preferencesConfig.get<string[]>('autoImportSpecifierExcludeRegexes'),
|
||||
preferTypeOnlyAutoImports: preferencesConfig.get<boolean>('preferTypeOnlyAutoImports', false),
|
||||
autoImportFileExcludePatterns: this.getAutoImportFileExcludePatternsPreference(document, fallbackSection, vscode.workspace.getWorkspaceFolder(document.uri)?.uri),
|
||||
autoImportSpecifierExcludeRegexes: readUnifiedConfig<string[] | undefined>('preferences.autoImportSpecifierExcludeRegexes', undefined, { scope: document, fallbackSection }),
|
||||
preferTypeOnlyAutoImports: readUnifiedConfig<boolean>('preferences.preferTypeOnlyAutoImports', false, { scope: document, fallbackSection }),
|
||||
useLabelDetailsInCompletionEntries: true,
|
||||
allowIncompleteCompletions: true,
|
||||
displayPartsForJSDoc: true,
|
||||
@@ -210,23 +206,16 @@ export default class FileConfigurationManager extends Disposable {
|
||||
interactiveInlayHints: true,
|
||||
includeCompletionsForModuleExports: readUnifiedConfig<boolean>('suggest.autoImports', true, { scope: document, fallbackSection }),
|
||||
...getInlayHintsPreferences(document, fallbackSection),
|
||||
...this.getOrganizeImportsPreferences(preferencesConfig),
|
||||
...getOrganizeImportsPreferences(document, fallbackSection),
|
||||
maximumHoverLength: this.getMaximumHoverLength(document),
|
||||
};
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
||||
private getQuoteStylePreference(config: vscode.WorkspaceConfiguration) {
|
||||
switch (config.get<string>('quoteStyle')) {
|
||||
case 'single': return 'single';
|
||||
case 'double': return 'double';
|
||||
default: return 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
private getAutoImportFileExcludePatternsPreference(config: vscode.WorkspaceConfiguration, workspaceFolder: vscode.Uri | undefined): string[] | undefined {
|
||||
return workspaceFolder && config.get<string[]>('autoImportFileExcludePatterns')?.map(p => {
|
||||
private getAutoImportFileExcludePatternsPreference(scope: vscode.ConfigurationScope, fallbackSection: string, workspaceFolder: vscode.Uri | undefined): string[] | undefined {
|
||||
const patterns = readUnifiedConfig<string[] | undefined>('preferences.autoImportFileExcludePatterns', undefined, { scope, fallbackSection });
|
||||
return workspaceFolder && patterns?.map(p => {
|
||||
// Normalization rules: https://github.com/microsoft/TypeScript/pull/49578
|
||||
const isRelative = /^\.\.?($|[\/\\])/.test(p);
|
||||
// In TypeScript < 5.3, the first path component cannot be a wildcard, so we need to prefix
|
||||
@@ -241,27 +230,6 @@ export default class FileConfigurationManager extends Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
private getOrganizeImportsPreferences(config: vscode.WorkspaceConfiguration): Proto.UserPreferences {
|
||||
const organizeImportsCollation = config.get<'ordinal' | 'unicode'>('organizeImports.unicodeCollation');
|
||||
const organizeImportsCaseSensitivity = config.get<'auto' | 'caseInsensitive' | 'caseSensitive'>('organizeImports.caseSensitivity');
|
||||
return {
|
||||
// More specific settings
|
||||
organizeImportsTypeOrder: withDefaultAsUndefined(config.get<'auto' | 'last' | 'inline' | 'first'>('organizeImports.typeOrder', 'auto'), 'auto'),
|
||||
organizeImportsIgnoreCase: organizeImportsCaseSensitivity === 'caseInsensitive' ? true
|
||||
: organizeImportsCaseSensitivity === 'caseSensitive' ? false
|
||||
: 'auto',
|
||||
organizeImportsCollation,
|
||||
|
||||
// The rest of the settings are only applicable when using unicode collation
|
||||
...(organizeImportsCollation === 'unicode' ? {
|
||||
organizeImportsCaseFirst: organizeImportsCaseSensitivity === 'caseInsensitive' ? undefined : withDefaultAsUndefined(config.get<'default' | 'upper' | 'lower' | false>('organizeImports.caseFirst', false), 'default'),
|
||||
organizeImportsAccentCollation: config.get<boolean>('organizeImports.accentCollation'),
|
||||
organizeImportsLocale: config.get<string>('organizeImports.locale'),
|
||||
organizeImportsNumericCollation: config.get<boolean>('organizeImports.numericCollation'),
|
||||
} : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private getMaximumHoverLength(document: vscode.TextDocument): number {
|
||||
const defaultMaxLength = 500;
|
||||
@@ -310,8 +278,16 @@ function getInlayParameterNameHintsPreference(scope: vscode.ConfigurationScope,
|
||||
}
|
||||
}
|
||||
|
||||
function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguration) {
|
||||
switch (config.get<string>('importModuleSpecifier')) {
|
||||
function getQuoteStylePreference(scope: vscode.ConfigurationScope, fallbackSection: string) {
|
||||
switch (readUnifiedConfig<string>('preferences.quoteStyle', 'auto', { scope, fallbackSection })) {
|
||||
case 'single': return 'single';
|
||||
case 'double': return 'double';
|
||||
default: return 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
function getImportModuleSpecifierPreference(scope: vscode.ConfigurationScope, fallbackSection: string) {
|
||||
switch (readUnifiedConfig<string>('preferences.importModuleSpecifier', 'shortest', { scope, fallbackSection })) {
|
||||
case 'project-relative': return 'project-relative';
|
||||
case 'relative': return 'relative';
|
||||
case 'non-relative': return 'non-relative';
|
||||
@@ -319,8 +295,8 @@ function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguratio
|
||||
}
|
||||
}
|
||||
|
||||
function getImportModuleSpecifierEndingPreference(config: vscode.WorkspaceConfiguration) {
|
||||
switch (config.get<string>('importModuleSpecifierEnding')) {
|
||||
function getImportModuleSpecifierEndingPreference(scope: vscode.ConfigurationScope, fallbackSection: string) {
|
||||
switch (readUnifiedConfig<string>('preferences.importModuleSpecifierEnding', 'auto', { scope, fallbackSection })) {
|
||||
case 'minimal': return 'minimal';
|
||||
case 'index': return 'index';
|
||||
case 'js': return 'js';
|
||||
@@ -328,10 +304,31 @@ function getImportModuleSpecifierEndingPreference(config: vscode.WorkspaceConfig
|
||||
}
|
||||
}
|
||||
|
||||
function getJsxAttributeCompletionStyle(config: vscode.WorkspaceConfiguration) {
|
||||
switch (config.get<string>('jsxAttributeCompletionStyle')) {
|
||||
function getJsxAttributeCompletionStyle(scope: vscode.ConfigurationScope, fallbackSection: string) {
|
||||
switch (readUnifiedConfig<string>('preferences.jsxAttributeCompletionStyle', 'auto', { scope, fallbackSection })) {
|
||||
case 'braces': return 'braces';
|
||||
case 'none': return 'none';
|
||||
default: return 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
function getOrganizeImportsPreferences(scope: vscode.ConfigurationScope, fallbackSection: string): Proto.UserPreferences {
|
||||
const organizeImportsCollation = readUnifiedConfig<'ordinal' | 'unicode'>('preferences.organizeImports.unicodeCollation', 'ordinal', { scope, fallbackSection });
|
||||
const organizeImportsCaseSensitivity = readUnifiedConfig<'auto' | 'caseInsensitive' | 'caseSensitive'>('preferences.organizeImports.caseSensitivity', 'auto', { scope, fallbackSection });
|
||||
return {
|
||||
// More specific settings
|
||||
organizeImportsTypeOrder: withDefaultAsUndefined(readUnifiedConfig<'auto' | 'last' | 'inline' | 'first'>('preferences.organizeImports.typeOrder', 'auto', { scope, fallbackSection }), 'auto'),
|
||||
organizeImportsIgnoreCase: organizeImportsCaseSensitivity === 'caseInsensitive' ? true
|
||||
: organizeImportsCaseSensitivity === 'caseSensitive' ? false
|
||||
: 'auto',
|
||||
organizeImportsCollation,
|
||||
|
||||
// The rest of the settings are only applicable when using unicode collation
|
||||
...(organizeImportsCollation === 'unicode' ? {
|
||||
organizeImportsCaseFirst: organizeImportsCaseSensitivity === 'caseInsensitive' ? undefined : withDefaultAsUndefined(readUnifiedConfig<'default' | 'upper' | 'lower' | false>('preferences.organizeImports.caseFirst', false, { scope, fallbackSection }), 'default'),
|
||||
organizeImportsAccentCollation: readUnifiedConfig<boolean | undefined>('preferences.organizeImports.accentCollation', undefined, { scope, fallbackSection }),
|
||||
organizeImportsLocale: readUnifiedConfig<string | undefined>('preferences.organizeImports.locale', undefined, { scope, fallbackSection }),
|
||||
organizeImportsNumericCollation: readUnifiedConfig<boolean | undefined>('preferences.organizeImports.numericCollation', undefined, { scope, fallbackSection }),
|
||||
} : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { API } from '../tsServer/api';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import * as typeConverters from '../typeConverters';
|
||||
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { readUnifiedConfig } from '../utils/configuration';
|
||||
import FileConfigurationManager from './fileConfigurationManager';
|
||||
import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration';
|
||||
import { LanguageDescription } from '../configuration/languageDescription';
|
||||
@@ -112,7 +113,7 @@ class TypeScriptRenameProvider implements vscode.RenameProvider {
|
||||
|
||||
// Prefer renaming matching jsx tag when available
|
||||
if (this.client.apiVersion.gte(API.v510) &&
|
||||
vscode.workspace.getConfiguration(this.language.id).get('preferences.renameMatchingJsxTags', true) &&
|
||||
readUnifiedConfig<boolean>('preferences.renameMatchingJsxTags', true, { scope: document, fallbackSection: this.language.id }) &&
|
||||
this.looksLikePotentialJsxTagContext(document, position)
|
||||
) {
|
||||
const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
|
||||
|
||||
@@ -20,8 +20,7 @@ suite.skip('TypeScript Completions', () => {
|
||||
[Config.insertMode]: 'insert',
|
||||
[Config.snippetSuggestions]: 'none',
|
||||
[Config.suggestSelection]: 'first',
|
||||
[Config.javascriptQuoteStyle]: 'double',
|
||||
[Config.typescriptQuoteStyle]: 'double',
|
||||
[Config.quoteStyle]: 'double',
|
||||
});
|
||||
|
||||
const _disposables: vscode.Disposable[] = [];
|
||||
|
||||
@@ -123,8 +123,7 @@ export const Config = Object.freeze({
|
||||
insertMode: 'editor.suggest.insertMode',
|
||||
snippetSuggestions: 'editor.snippetSuggestions',
|
||||
suggestSelection: 'editor.suggestSelection',
|
||||
javascriptQuoteStyle: 'javascript.preferences.quoteStyle',
|
||||
typescriptQuoteStyle: 'typescript.preferences.quoteStyle',
|
||||
quoteStyle: 'js/ts.preferences.quoteStyle',
|
||||
} as const);
|
||||
|
||||
export const insertModesValues = Object.freeze(['insert', 'replace']);
|
||||
|
||||
Reference in New Issue
Block a user