From cd16da88ef794f2da07d634011e6c42cb878a8f2 Mon Sep 17 00:00:00 2001 From: Qiming Zhao Date: Tue, 21 Dec 2021 17:00:49 +0800 Subject: [PATCH] feat: support suggest.classMemberSnippets.enabled configuration --- Readme.md | 5 ++++- package.json | 8 +++++++- src/server/features/fileConfigurationManager.ts | 10 +++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 0300baa..c9229fb 100644 --- a/Readme.md +++ b/Readme.md @@ -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` diff --git a/package.json b/package.json index 69f5bba..ea34e65 100644 --- a/package.json +++ b/package.json @@ -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, diff --git a/src/server/features/fileConfigurationManager.ts b/src/server/features/fileConfigurationManager.ts index 8c6e796..7a6635d 100644 --- a/src/server/features/fileConfigurationManager.ts +++ b/src/server/features/fileConfigurationManager.ts @@ -163,7 +163,7 @@ export default class FileConfigurationManager { importStatementSuggestions: config.get('importStatements', true), includeCompletionsForImportStatements: config.get('includeCompletionsForImportStatements', true), includeCompletionsWithSnippetText: config.get('includeCompletionsWithSnippetText', true), - includeCompletionsWithClassMemberSnippets: config.get('includeCompletionsWithClassMemberSnippets', true), + includeCompletionsWithClassMemberSnippets: config.get('classMemberSnippets.enabled', true), includeAutomaticOptionalChainCompletions: config.get('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('renameShorthandProperties', true) === false ? false : config.get('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 }