From 6c51d7f41369e85f14ab6050907544714801d70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 23 Aug 2021 16:52:45 +0800 Subject: cleanup hint --- script/provider/provider.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 4734686b..774e6c88 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -799,6 +799,28 @@ proto.on('textDocument/onTypeFormatting', function (params) return results end) +proto.on('$/requestHint', function (params) + local core = require 'core.hint' + await.setID 'hint' + await.close 'hint' + if not config.get 'Lua.hint.enable' then + return + end + workspace.awaitReady() + local uri = params.textDocument.uri + local start, finish = files.unrange(uri, params.range) + local results = core(uri, start, finish) + local hintResults = {} + for i, res in ipairs(results) do + hintResults[i] = { + text = res.text, + pos = files.position(uri, res.offset, res.where), + kind = res.kind, + } + end + return hintResults +end) + -- Hint do local function updateHint(uri) @@ -821,7 +843,7 @@ do if piece then for _, edit in ipairs(piece) do edits[#edits+1] = { - newText = ':' .. edit.text, + newText = edit.text, range = files.range(uri, edit.offset, edit.offset) } end -- cgit v1.2.3