add typescript.preferences.includePackageJsonAutoImports configuration

This commit is contained in:
Qiming Zhao 2021-12-21 17:38:28 +08:00
parent 5a8c68fc60
commit 4d78b618e4
4 changed files with 27 additions and 0 deletions

View file

@ -137,6 +137,9 @@ for guide of coc.nvim's configuration.
- `typescript.preferences.importModuleSpecifier` default: `"auto"` - `typescript.preferences.importModuleSpecifier` default: `"auto"`
- `typescript.preferences.importModuleSpecifierEnding` default: `"auto"` - `typescript.preferences.importModuleSpecifierEnding` default: `"auto"`
- `typescript.preferences.quoteStyle` default: `"single"` - `typescript.preferences.quoteStyle` default: `"single"`
- `typescript.preferences.includePackageJsonAutoImports`: Enable/disable
searching `package.json` dependencies for available auto imports, default:
`"auto"`
- `typescript.suggestionActions.enabled`:Enable/disable suggestion diagnostics - `typescript.suggestionActions.enabled`:Enable/disable suggestion diagnostics
for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in for TypeScript files in the editor. Requires using TypeScript 2.8 or newer in
the workspace., default: `true` the workspace., default: `true`

View file

@ -330,6 +330,22 @@
"description": "Preferred style for JSX attribute completions.", "description": "Preferred style for JSX attribute completions.",
"scope": "resource" "scope": "resource"
}, },
"typescript.preferences.includePackageJsonAutoImports": {
"type": "string",
"enum": [
"auto",
"on",
"off"
],
"enumDescriptions": [
"Search dependencies based on estimated performance impact.",
"Always search dependencies.",
"Never search dependencies."
],
"default": "auto",
"markdownDescription": "Enable/disable searching `package.json` dependencies for available auto imports.",
"scope": "window"
},
"typescript.preferences.quoteStyle": { "typescript.preferences.quoteStyle": {
"type": "string", "type": "string",
"default": "auto", "default": "auto",

View file

@ -408,6 +408,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
preferences: { preferences: {
providePrefixAndSuffixTextForRename: true, providePrefixAndSuffixTextForRename: true,
allowRenameOfImportPath: true, allowRenameOfImportPath: true,
includePackageJsonAutoImports: this._configuration.includePackageJsonAutoImports
}, },
watchOptions watchOptions
} }

View file

@ -40,14 +40,21 @@ export namespace TsServerLogLevel {
export class TypeScriptServiceConfiguration { export class TypeScriptServiceConfiguration {
private _configuration: WorkspaceConfiguration private _configuration: WorkspaceConfiguration
private _includePackageJsonAutoImports: 'auto' | 'on' | 'off'
private constructor() { private constructor() {
this._configuration = workspace.getConfiguration('tsserver') this._configuration = workspace.getConfiguration('tsserver')
this._includePackageJsonAutoImports = workspace.getConfiguration('typescript').get<'auto' | 'on' | 'off'>('preferences.includePackageJsonAutoImports')
workspace.onDidChangeConfiguration(() => { workspace.onDidChangeConfiguration(() => {
this._configuration = workspace.getConfiguration('tsserver') this._configuration = workspace.getConfiguration('tsserver')
this._includePackageJsonAutoImports = workspace.getConfiguration('typescript').get<'auto' | 'on' | 'off'>('preferences.includePackageJsonAutoImports')
}) })
} }
public get includePackageJsonAutoImports(): 'auto' | 'on' | 'off' {
return this._includePackageJsonAutoImports
}
public get locale(): string | null { public get locale(): string | null {
return this._configuration.get<string | null>('locale', null) return this._configuration.get<string | null>('locale', null)
} }