summaryrefslogtreecommitdiff
path: root/script/provider/provider.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-23 16:52:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-23 16:52:45 +0800
commit6c51d7f41369e85f14ab6050907544714801d70e (patch)
tree90db6ba6245176e7558273089585d5f2697673af /script/provider/provider.lua
parent4220ff641c7c2dba943eefe3d0a2e6d99cc523c6 (diff)
downloadlua-language-server-6c51d7f41369e85f14ab6050907544714801d70e.zip
cleanup hint
Diffstat (limited to 'script/provider/provider.lua')
-rw-r--r--script/provider/provider.lua24
1 files changed, 23 insertions, 1 deletions
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