From 1aa5d27dc035e8281127288b2edc7740f7f9229f Mon Sep 17 00:00:00 2001 From: CppCXY <812125110@qq.com> Date: Thu, 28 Oct 2021 14:32:06 +0800 Subject: =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/provider/provider.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index ac16c4e3..42c0af0d 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -801,6 +801,29 @@ proto.on('textDocument/onTypeFormatting', function (params) return results end) +proto.on('textDocument/formatting', function (params) + workspace.awaitReady() + local _ = progress.create(lang.script.WINDOW_PROCESSING_TYPE_FORMATTING, 0.5) + local uri = params.textDocument.uri + if not files.exists(uri) then + return nil + end + local core = require 'core.formatting' + + local status, range, formattedText = core(uri) + if status then + local results = { + { + range = range, + newText = formattedText, + } + } + return results + end + + return nil +end) + proto.on('$/cancelRequest', function (params) proto.close(params.id, define.ErrorCodes.RequestCancelled) end) -- cgit v1.2.3