Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a quick way to disable or enable all optional settings #96

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 5 additions & 1 deletion src/configurationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
*/
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/completions/objectLiteralHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default (node: ts.Node, entries: ts.CompletionEntry[]): ts.CompletionEntr
if (ts.isObjectLiteralExpression(node) && isArrayLike(entries)) {
return [
{
name: '(array)',
name: '<array properties>',
kind: ts.ScriptElementKind.label,
sortText: '07',
insertText: '[]',
Expand Down
5 changes: 3 additions & 2 deletions typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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()
}
Expand Down
23 changes: 23 additions & 0 deletions typescript/src/patchConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Configuration } from './types'

const excludeToDisable: Array<keyof Configuration> = ['enablePlugin', 'enableVueSupport']
const optionalExperiencesSettings: Partial<Configuration> = {
'suggestions.keywordsInsertText': 'none',
'markTsCodeFixes.character': '',
}

const recommendedSettings: Partial<Configuration> = {
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
}