summaryrefslogtreecommitdiff
path: root/script-beta/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-11 11:45:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-11 11:45:30 +0800
commit05de2e6caecc62c4c6e16ec5256fd98a07c88d03 (patch)
treef292fb09a0fd9c2fe26ca3942effe727c2d122f8 /script-beta/provider
parent152eb100b8cf9fdb5eb26b7ab4ee22cf86c8c6dc (diff)
downloadlua-language-server-05de2e6caecc62c4c6e16ec5256fd98a07c88d03.zip
如果时间充裕,先本地解决一部分详情,减少窗口闪动
Diffstat (limited to 'script-beta/provider')
-rw-r--r--script-beta/provider/init.lua24
1 files changed, 19 insertions, 5 deletions
diff --git a/script-beta/provider/init.lua b/script-beta/provider/init.lua
index 67af9bb0..4ce39bbc 100644
--- a/script-beta/provider/init.lua
+++ b/script-beta/provider/init.lua
@@ -315,19 +315,33 @@ proto.on('textDocument/completion', function (params)
if not result then
return nil
end
+ local easy = true
local items = {}
for i, res in ipairs(result) do
- items[i] = {
+ local item = {
label = res.label,
kind = res.kind,
- data = res.id and {
- version = files.globalVersion,
- id = res.id,
- },
sortText = ('%04d'):format(i),
insertText = res.insertText,
insertTextFormat = res.insertTextFormat,
}
+ if res.id then
+ if easy and os.clock() - clock < 0.05 then
+ local resolved = core.resolve(res.id)
+ item.detail = resolved.detail
+ item.documentation = resolved.description and {
+ value = resolved.description,
+ kind = 'markdown',
+ }
+ else
+ easy = false
+ item.data = {
+ version = files.globalVersion,
+ id = res.id,
+ }
+ end
+ end
+ items[i] = item
end
return items
end)