From fc4519a82149e5fa14d083997352af4cb339e331 Mon Sep 17 00:00:00 2001 From: chemzqm Date: Tue, 11 Sep 2018 00:51:17 +0800 Subject: [PATCH] remove formatOnSave option --- package.json | 5 ----- src/index.ts | 23 +---------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/package.json b/package.json index 2ac7546..c7cb11e 100644 --- a/package.json +++ b/package.json @@ -68,11 +68,6 @@ "default": "", "description": "Folder path for cache typings" }, - "tsserver.formatOnSave": { - "type": "boolean", - "default": false, - "description": "Format document on buffer will save" - }, "tsserver.orgnizeImportOnSave": { "type": "boolean", "default": false, diff --git a/src/index.ts b/src/index.ts index 5856675..74b4758 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,6 @@ -import { commands, ExtensionContext, languages, services, ServiceStat, TextDocumentWillSaveEvent, workspace } from 'coc.nvim' -import { TextEdit } from 'vscode-languageserver-types' +import { commands, ExtensionContext, services, workspace } from 'coc.nvim' import TsserverService from './server' import { Command, OpenTsServerLogCommand, ReloadProjectsCommand, TypeScriptGoToProjectConfigCommand } from './server/commands' -import { languageIds } from './server/utils/languageModeIds' export async function activate(context: ExtensionContext): Promise { let { subscriptions } = context @@ -14,21 +12,6 @@ export async function activate(context: ExtensionContext): Promise { (services as any).regist(service) ) - function onWillSave(event: TextDocumentWillSaveEvent): void { - if (service.state != ServiceStat.Running) return - let config = service.config - let formatOnSave = config.get('formatOnSave') - if (!formatOnSave) return - let { languageId } = event.document - if (languageIds.indexOf(languageId) == -1) return - let willSaveWaitUntil = async (): Promise => { - 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 { let { id, execute } = cmd subscriptions.push(commands.registerCommand(id as string, execute, cmd)) @@ -47,8 +30,4 @@ export async function activate(context: ExtensionContext): Promise { }) } })) - - subscriptions.push( - workspace.onWillSaveUntil(onWillSave, null, 'tsserver') - ) }