remove formatOnSave option
This commit is contained in:
parent
fb91633843
commit
fc4519a821
2 changed files with 1 additions and 27 deletions
|
@ -68,11 +68,6 @@
|
||||||
"default": "",
|
"default": "",
|
||||||
"description": "Folder path for cache typings"
|
"description": "Folder path for cache typings"
|
||||||
},
|
},
|
||||||
"tsserver.formatOnSave": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false,
|
|
||||||
"description": "Format document on buffer will save"
|
|
||||||
},
|
|
||||||
"tsserver.orgnizeImportOnSave": {
|
"tsserver.orgnizeImportOnSave": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
|
|
23
src/index.ts
23
src/index.ts
|
@ -1,8 +1,6 @@
|
||||||
import { commands, ExtensionContext, languages, services, ServiceStat, TextDocumentWillSaveEvent, workspace } from 'coc.nvim'
|
import { commands, ExtensionContext, services, workspace } from 'coc.nvim'
|
||||||
import { TextEdit } from 'vscode-languageserver-types'
|
|
||||||
import TsserverService from './server'
|
import TsserverService from './server'
|
||||||
import { Command, OpenTsServerLogCommand, ReloadProjectsCommand, TypeScriptGoToProjectConfigCommand } from './server/commands'
|
import { Command, OpenTsServerLogCommand, ReloadProjectsCommand, TypeScriptGoToProjectConfigCommand } from './server/commands'
|
||||||
import { languageIds } from './server/utils/languageModeIds'
|
|
||||||
|
|
||||||
export async function activate(context: ExtensionContext): Promise<void> {
|
export async function activate(context: ExtensionContext): Promise<void> {
|
||||||
let { subscriptions } = context
|
let { subscriptions } = context
|
||||||
|
@ -14,21 +12,6 @@ export async function activate(context: ExtensionContext): Promise<void> {
|
||||||
(services as any).regist(service)
|
(services as any).regist(service)
|
||||||
)
|
)
|
||||||
|
|
||||||
function onWillSave(event: TextDocumentWillSaveEvent): void {
|
|
||||||
if (service.state != ServiceStat.Running) return
|
|
||||||
let config = service.config
|
|
||||||
let formatOnSave = config.get<boolean>('formatOnSave')
|
|
||||||
if (!formatOnSave) return
|
|
||||||
let { languageId } = event.document
|
|
||||||
if (languageIds.indexOf(languageId) == -1) return
|
|
||||||
let willSaveWaitUntil = async (): Promise<TextEdit[]> => {
|
|
||||||
let options = await workspace.getFormatOptions(event.document.uri)
|
|
||||||
let textEdits = await languages.provideDocumentFormattingEdits(event.document, options)
|
|
||||||
return textEdits
|
|
||||||
}
|
|
||||||
event.waitUntil(willSaveWaitUntil())
|
|
||||||
}
|
|
||||||
|
|
||||||
function registCommand(cmd: Command): void {
|
function registCommand(cmd: Command): void {
|
||||||
let { id, execute } = cmd
|
let { id, execute } = cmd
|
||||||
subscriptions.push(commands.registerCommand(id as string, execute, cmd))
|
subscriptions.push(commands.registerCommand(id as string, execute, cmd))
|
||||||
|
@ -47,8 +30,4 @@ export async function activate(context: ExtensionContext): Promise<void> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
subscriptions.push(
|
|
||||||
workspace.onWillSaveUntil(onWillSave, null, 'tsserver')
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue