feat: includeCompletionsWithClassMemberSnippets (#321)

* docs: update yarn configuration (#311)

* feat: includeCompletionsWithClassMemberSnippets

typescript.suggest.includeCompletionsWithClassMemberSnippets

Co-authored-by: KY64 <31939494+KY64@users.noreply.github.com>
This commit is contained in:
Heyward Fann 2021-12-21 13:54:47 +08:00 committed by GitHub
parent 065abccd88
commit 2d52a842cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 1 deletions

View file

@ -156,6 +156,9 @@ 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
snippet completions for class members. Requires using TypeScript 4.5+ in the
workspace, default: `true`
- `typescript.format.enabled`:Enable/disable format of typescript files.
- `typescript.format.insertSpaceAfterCommaDelimiter` default: `true`
- `typescript.format.insertSpaceAfterConstructor` default: `false`

View file

@ -390,6 +390,12 @@
"description": "Enable/disable snippet completions from TS Server. Requires using TypeScript 4.3+ in the workspace.",
"scope": "resource"
},
"typescript.suggest.includeCompletionsWithClassMemberSnippets": {
"type": "boolean",
"default": true,
"description": "Enable/disable snippet completions for class members. Requires using TypeScript 4.5+ in the workspace",
"scope": "resource"
},
"typescript.format.enabled": {
"type": "boolean",
"default": true,

View file

@ -259,7 +259,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
item.additionalTextEdits = additionalTextEdits
if (detail && item.insertTextFormat == InsertTextFormat.Snippet) {
const shouldCompleteFunction = await this.isValidFunctionCompletionContext(filepath, position, token)
if (shouldCompleteFunction) {
if (shouldCompleteFunction && !item.insertText) {
this.createSnippetOfFunctionCall(item, detail)
}
}

View file

@ -40,6 +40,7 @@ export interface SuggestOptions {
readonly importStatementSuggestions: boolean
readonly includeCompletionsForImportStatements: boolean
readonly includeCompletionsWithSnippetText: boolean
readonly includeCompletionsWithClassMemberSnippets: boolean
}
export default class FileConfigurationManager {
@ -162,6 +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),
includeAutomaticOptionalChainCompletions: config.get<boolean>('includeAutomaticOptionalChainCompletions', true)
}
}
@ -182,6 +184,7 @@ export default class FileConfigurationManager {
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,
}
return preferences