support format.enabled configuration
This commit is contained in:
parent
f9309a6d80
commit
07e857d965
3 changed files with 28 additions and 12 deletions
14
Readme.md
14
Readme.md
|
@ -87,6 +87,7 @@ this extension.
|
|||
- `typescript.suggest.paths`:Enable/disable suggest paths in import statement and require calls, default: `true`
|
||||
- `typescript.suggest.autoImports`:Enable/disable auto import suggests., default: `true`
|
||||
- `typescript.suggest.completeFunctionCalls`:Enable snippet for method suggestion, default: `true`
|
||||
- `typescript.format.enabled`:Enable/disable format of typescript files.
|
||||
- `typescript.format.insertSpaceAfterCommaDelimiter` default: `true`
|
||||
- `typescript.format.insertSpaceAfterConstructor` default: `false`
|
||||
- `typescript.format.insertSpaceAfterSemicolonInForStatements` default: `true`
|
||||
|
@ -102,18 +103,19 @@ this extension.
|
|||
- `typescript.format.insertSpaceAfterTypeAssertion` default: `false`
|
||||
- `typescript.format.placeOpenBraceOnNewLineForFunctions` default: `false`
|
||||
- `typescript.format.placeOpenBraceOnNewLineForControlBlocks` default: `false`
|
||||
- `javascript.format.enabled`: Enable/disable format for javascript files.
|
||||
- `javascript.showUnused`: show unused variable hint.
|
||||
- `javascript.updateImportsOnFileMove.enable` default: `true`
|
||||
- `javascript.implementationsCodeLens.enable` default: `true`
|
||||
- `javascript.referencesCodeLens.enable` default: `true`
|
||||
- `javascript.preferences.importModuleSpecifier` default: `"non-relative"`
|
||||
- `javascript.preferences.quoteStyle` default: `"single"`
|
||||
- `javascript.validate.enable`:Enable/disable JavaScript validation., default: `true`
|
||||
- `javascript.suggestionActions.enabled`:Enable/disable suggestion diagnostics for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace., default: `true`
|
||||
- `javascript.suggest.names` default: `true`
|
||||
- `javascript.suggest.enabled` default: `true`
|
||||
- `javascript.suggest.paths`:Enable/disable suggest paths in import statement and require calls, default: `true`
|
||||
- `javascript.suggest.autoImports`:Enable/disable auto import suggests., default: `true`
|
||||
- `javascript.validate.enable`: Enable/disable JavaScript validation., default: `true`
|
||||
- `javascript.suggestionActions.enabled`: Enable/disable suggestion diagnostics for JavaScript files in the editor. Requires using TypeScript 2.8 or newer in the workspace., default: `true`
|
||||
- `javascript.suggest.names`: default `true`
|
||||
- `javascript.suggest.enabled`: default `true`
|
||||
- `javascript.suggest.paths`: Enable/disable suggest paths in import statement and require calls, default: `true`
|
||||
- `javascript.suggest.autoImports`: Enable/disable auto import suggests., default: `true`
|
||||
- `javascript.suggest.completeFunctionCalls`:Enable snippet for method suggestion, default: `true`
|
||||
- `javascript.format.insertSpaceAfterCommaDelimiter` default: `true`
|
||||
- `javascript.format.insertSpaceAfterConstructor` default: `false`
|
||||
|
|
10
package.json
10
package.json
|
@ -268,6 +268,11 @@
|
|||
"default": true,
|
||||
"description": "Enable snippet for method suggestion"
|
||||
},
|
||||
"typescript.format.enabled": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enable format for typescript."
|
||||
},
|
||||
"typescript.format.insertSpaceAfterCommaDelimiter": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
|
@ -395,6 +400,11 @@
|
|||
"default": true,
|
||||
"description": "Enable snippet for method suggestion"
|
||||
},
|
||||
"javascript.format.enabled": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enable format for javascript."
|
||||
},
|
||||
"javascript.format.insertSpaceAfterCommaDelimiter": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
|
|
|
@ -20,12 +20,17 @@ export default class TypeScriptFormattingProvider
|
|||
) {
|
||||
}
|
||||
|
||||
private enabled(document: TextDocument): boolean {
|
||||
return this.formattingOptionsManager.formatEnabled(document)
|
||||
}
|
||||
|
||||
private async doFormat(
|
||||
document: TextDocument,
|
||||
options: FormattingOptions,
|
||||
args: Proto.FormatRequestArgs,
|
||||
token?: CancellationToken
|
||||
): Promise<TextEdit[]> {
|
||||
if (!this.enabled(document)) return []
|
||||
await this.formattingOptionsManager.ensureConfigurationOptions(
|
||||
document,
|
||||
options.insertSpaces,
|
||||
|
@ -49,6 +54,7 @@ export default class TypeScriptFormattingProvider
|
|||
options: FormattingOptions,
|
||||
token: CancellationToken
|
||||
): Promise<TextEdit[]> {
|
||||
if (!this.enabled(document)) return []
|
||||
const filepath = this.client.toPath(document.uri)
|
||||
if (!filepath) return []
|
||||
const args: Proto.FormatRequestArgs = {
|
||||
|
@ -66,6 +72,7 @@ export default class TypeScriptFormattingProvider
|
|||
options: FormattingOptions,
|
||||
token?: CancellationToken
|
||||
): Promise<TextEdit[]> {
|
||||
if (!this.enabled(document)) return []
|
||||
const filepath = this.client.toPath(document.uri)
|
||||
if (!filepath) return []
|
||||
const args: Proto.FormatRequestArgs = {
|
||||
|
@ -85,13 +92,10 @@ export default class TypeScriptFormattingProvider
|
|||
options: FormattingOptions,
|
||||
token: CancellationToken
|
||||
): Promise<TextEdit[]> {
|
||||
if (!this.client.configuration.formatOnType) {
|
||||
return
|
||||
}
|
||||
if (!this.enabled(document)) return []
|
||||
if (!this.client.configuration.formatOnType) return []
|
||||
const file = this.client.toPath(document.uri)
|
||||
if (!file) {
|
||||
return []
|
||||
}
|
||||
if (!file) return []
|
||||
|
||||
await this.formattingOptionsManager.ensureConfigurationOptions(
|
||||
document,
|
||||
|
|
Loading…
Reference in a new issue