feat: support suggest.classMemberSnippets.enabled configuration

This commit is contained in:
Qiming Zhao 2021-12-21 17:00:49 +08:00
parent 30a23e2454
commit cd16da88ef
3 changed files with 16 additions and 7 deletions

View file

@ -156,7 +156,7 @@ for guide of coc.nvim's configuration.
TypeScript 4.3+ in the workspace, default: `true`
- `typescript.suggest.includeCompletionsWithSnippetText`: Enable snippet completions
from TS Server. Requires using TypeScript 4.3+ in the workspace, default: `true`
- `typescript.suggest.includeCompletionsWithClassMemberSnippets`: Enable/disable
- `typescript.suggest.classMemberSnippets.enabled`: Enable/disable
snippet completions for class members. Requires using TypeScript 4.5+ in the
workspace, default: `true`
- `typescript.format.enabled`:Enable/disable format of typescript files.
@ -210,6 +210,9 @@ for guide of coc.nvim's configuration.
- `javascript.suggest.includeCompletionsForImportStatements`: Enable/disable
auto-import-style completions on partially-typed import statements. Requires
using TypeScript 4.3+ in the workspace, default: `true`
- `javascript.suggest.classMemberSnippets.enabled`: Enable/disable
snippet completions for class members. Requires using TypeScript 4.5+ in the
workspace, default: `true`
- `javascript.format.insertSpaceAfterCommaDelimiter` default: `true`
- `javascript.format.insertSpaceAfterConstructor` default: `false`
- `javascript.format.insertSpaceAfterSemicolonInForStatements` default: `true`

View file

@ -390,7 +390,7 @@
"description": "Enable/disable snippet completions from TS Server. Requires using TypeScript 4.3+ in the workspace.",
"scope": "resource"
},
"typescript.suggest.includeCompletionsWithClassMemberSnippets": {
"typescript.suggest.classMemberSnippets.enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable snippet completions for class members. Requires using TypeScript 4.5+ in the workspace",
@ -616,6 +616,12 @@
"description": "Enable/disable auto-import-style completions on partially-typed import statements. Requires using TypeScript 4.3+ in the workspace.",
"scope": "resource"
},
"javascript.suggest.classMemberSnippets.enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable snippet completions for class members. Requires using TypeScript 4.5+ in the workspace",
"scope": "resource"
},
"javascript.format.enabled": {
"type": "boolean",
"default": true,

View file

@ -163,7 +163,7 @@ export default class FileConfigurationManager {
importStatementSuggestions: config.get<boolean>('importStatements', true),
includeCompletionsForImportStatements: config.get<boolean>('includeCompletionsForImportStatements', true),
includeCompletionsWithSnippetText: config.get<boolean>('includeCompletionsWithSnippetText', true),
includeCompletionsWithClassMemberSnippets: config.get<boolean>('includeCompletionsWithClassMemberSnippets', true),
includeCompletionsWithClassMemberSnippets: config.get<boolean>('classMemberSnippets.enabled', true),
includeAutomaticOptionalChainCompletions: config.get<boolean>('includeAutomaticOptionalChainCompletions', true)
}
}
@ -173,19 +173,19 @@ export default class FileConfigurationManager {
return {}
}
const config = workspace.getConfiguration(`${language}.preferences`, uri)
const suggestConfig = this.getCompleteOptions(language)
// getImportModuleSpecifierEndingPreference available on ts 2.9.0
const preferences: Proto.UserPreferences & { importModuleSpecifierEnding?: string } = {
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),
includeCompletionsForImportStatements: this.getCompleteOptions(language).includeCompletionsForImportStatements,
includeCompletionsWithClassMemberSnippets: this.getCompleteOptions(language).includeCompletionsWithClassMemberSnippets,
includeCompletionsWithSnippetText: this.getCompleteOptions(language).includeCompletionsWithSnippetText,
includeCompletionsForImportStatements: suggestConfig.includeCompletionsForImportStatements,
includeCompletionsWithClassMemberSnippets: suggestConfig.includeCompletionsWithClassMemberSnippets,
includeCompletionsWithSnippetText: suggestConfig.includeCompletionsWithSnippetText,
}
return preferences
}