From 0a6ee72e10dd809a6e3da8658f25b958abfee95a Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 7 Feb 2023 05:28:53 +0300 Subject: [PATCH 1/2] wip --- src/configurationType.ts | 6 ++++- .../src/completions/objectLiteralHelpers.ts | 2 +- typescript/src/index.ts | 5 ++-- typescript/src/patchConfig.ts | 23 +++++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 typescript/src/patchConfig.ts diff --git a/src/configurationType.ts b/src/configurationType.ts index 6af105d7..71b82b1d 100644 --- a/src/configurationType.ts +++ b/src/configurationType.ts @@ -48,7 +48,6 @@ type ReplaceRule = { } // For easier testing, specify every default -// TODO support scripting export type Configuration = { /** * Controls wether TypeScript Essentials plugin is enabled or not. @@ -63,6 +62,11 @@ export type Configuration = { * @default false */ enableVueSupport: boolean + /** + * Override default setting values (except `enablePlugin` and `enableVueSupport`) + * @default 'no-override' + */ + // overrideDefaults: 'no-override' | 'all-off' | 'recommended' | 'all-on' /** * Temporary setting to enable loading config from other locations (also to expose plugin) */ diff --git a/typescript/src/completions/objectLiteralHelpers.ts b/typescript/src/completions/objectLiteralHelpers.ts index 171227ce..a13a3bdc 100644 --- a/typescript/src/completions/objectLiteralHelpers.ts +++ b/typescript/src/completions/objectLiteralHelpers.ts @@ -5,7 +5,7 @@ export default (node: ts.Node, entries: ts.CompletionEntry[]): ts.CompletionEntr if (ts.isObjectLiteralExpression(node) && isArrayLike(entries)) { return [ { - name: '(array)', + name: '', kind: ts.ScriptElementKind.label, sortText: '07', insertText: '[]', diff --git a/typescript/src/index.ts b/typescript/src/index.ts index add035dc..2b1a0883 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -2,6 +2,7 @@ //@ts-ignore import type { Configuration } from '../../src/configurationType' import { decorateLanguageService, getInitialProxy, thisPluginMarker } from './decorateProxy' +import patchConfig from './patchConfig' let _configObj = { config: undefined! as Configuration, @@ -14,7 +15,7 @@ const plugin: ts.server.PluginModuleFactory = ({ typescript }) => { return { create(info) { // receive fresh config - _configObj.config = info.config + _configObj.config = patchConfig(info.config) console.log('receive config', JSON.stringify(_configObj.config)) if (info.languageService[thisPluginMarker]) return info.languageService @@ -43,7 +44,7 @@ const plugin: ts.server.PluginModuleFactory = ({ typescript }) => { }, onConfigurationChanged(config) { console.log('update config', JSON.stringify(config)) - _configObj.config = config + _configObj.config = patchConfig(config) for (const updateConfigListener of updateConfigListeners) { updateConfigListener() } diff --git a/typescript/src/patchConfig.ts b/typescript/src/patchConfig.ts new file mode 100644 index 00000000..d0e56e51 --- /dev/null +++ b/typescript/src/patchConfig.ts @@ -0,0 +1,23 @@ +import { Configuration } from './types' + +const excludeToDisable: Array = ['enablePlugin', 'enableVueSupport'] +const optionalExperiencesSettings: Partial = { + 'suggestions.keywordsInsertText': 'none', + 'markTsCodeFixes.character': '', +} + +const recommendedSettings: Partial = { + enableVueSupport: true, + patchOutline: true, + 'arrayMethodsSnippets.enable': true, + fixSuggestionsSorting: true, + removeModuleFileDefinitions: true, + enableFileDefinitions: true, + workspaceSymbolSearchExcludePatterns: ['**/node_modules/**'], + disableUselessHighlighting: 'inJsxArttributeStrings', + 'experiments.excludeNonJsxCompletions': true, +} + +export default (config: Configuration) => { + return config +} From 3c20d2ed7d41a79567d818c2d09c6e06e1aaec40 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 7 Feb 2023 05:29:32 +0300 Subject: [PATCH 2/2] doc --- README.MD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.MD b/README.MD index 404f70c6..36e9a7de 100644 --- a/README.MD +++ b/README.MD @@ -8,6 +8,8 @@ See [special commands list](#special-commands-list) ans [code actions list](#contributed-code-actions) +> Note: you can disable all optional features `tsEssentialPlugins.overrideDefaults` setting right after install. + ### JSX Outline (*disabled by default*) Enable with `tsEssentialPlugins.patchOutline`