Skip to content

Commit

Permalink
feat: add jsxAttributeCompletionStyle settings
Browse files Browse the repository at this point in the history
  • Loading branch information
fannheyward committed Oct 11, 2021
1 parent 5306fc3 commit 9b913fc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,22 @@
"description": "Preferred path ending for auto imports.",
"scope": "resource"
},
"typescript.preferences.jsxAttributeCompletionStyle": {
"type": "string",
"enum": [
"auto",
"braces",
"none"
],
"markdownEnumDescriptions": [
"Insert `={}` or `=\"\"` after attribute names based on the prop type.",
"Insert `={}` after attribute names.",
"Only insert attribute names."
],
"default": "auto",
"description": "Preferred style for JSX attribute completions.",
"scope": "resource"
},
"typescript.preferences.quoteStyle": {
"type": "string",
"default": "auto",
Expand Down Expand Up @@ -524,6 +540,22 @@
"description": "Preferred path ending for auto imports.",
"scope": "resource"
},
"javascript.preferences.jsxAttributeCompletionStyle": {
"type": "string",
"enum": [
"auto",
"braces",
"none"
],
"markdownEnumDescriptions": [
"Insert `={}` or `=\"\"` after attribute names based on the prop type.",
"Insert `={}` after attribute names.",
"Only insert attribute names."
],
"default": "auto",
"description": "Preferred style for JSX attribute completions.",
"scope": "resource"
},
"javascript.preferences.quoteStyle": {
"type": "string",
"default": "auto",
Expand Down
10 changes: 10 additions & 0 deletions src/server/features/fileConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export default class FileConfigurationManager {
quotePreference: this.getQuoteStyle(config),
importModuleSpecifierPreference: getImportModuleSpecifier(config) as any,
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(config),
// @ts-expect-error until TS 4.5 protocol update
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(config),
allowTextChangesInNewFiles: uri.startsWith('file:'),
allowRenameOfImportPath: true,
providePrefixAndSuffixTextForRename: config.get<boolean>('renameShorthandProperties', true) === false ? false : config.get<boolean>('useAliasesForRenames', true),
Expand Down Expand Up @@ -220,3 +222,11 @@ function getImportModuleSpecifierEndingPreference(config: WorkspaceConfiguration
default: return 'auto'
}
}

function getJsxAttributeCompletionStyle(config: WorkspaceConfiguration) {
switch (config.get<string>('jsxAttributeCompletionStyle')) {
case 'braces': return 'braces'
case 'none': return 'none'
default: return 'auto'
}
}

0 comments on commit 9b913fc

Please sign in to comment.