summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-02 19:44:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-02 19:44:35 +0800
commit95437dacc0ecfdf7ee6c4b158fbba6dbc21aecd3 (patch)
treeaeb736b38def3368eaa49d7bd863e72d0f59b97d
parent36a5c10b00160c85a8c29170b5d5de8b27b4a5c9 (diff)
downloadlua-language-server-95437dacc0ecfdf7ee6c4b158fbba6dbc21aecd3.zip
update hover of async
-rw-r--r--script/await.lua2
-rw-r--r--script/core/hover/label.lua6
-rw-r--r--test/hover/init.lua8
3 files changed, 14 insertions, 2 deletions
diff --git a/script/await.lua b/script/await.lua
index a887664a..cea5667b 100644
--- a/script/await.lua
+++ b/script/await.lua
@@ -25,7 +25,7 @@ local function setID(id, co, callback)
end
--- 设置错误处理器
----@param errHandle function {comment = '当有错误发生时,会以错误堆栈为参数调用该函数'}
+---@param errHandle function # 当有错误发生时,会以错误堆栈为参数调用该函数
function m.setErrorHandle(errHandle)
m.errorHandle = errHandle
end
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index 44459bb6..803b9596 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -16,7 +16,11 @@ local function asFunction(source, oop)
local arg = buildArg(source, oop)
local rtn = buildReturn(source)
local lines = {}
- lines[1] = ('%s %s(%s)'):format(oop and 'method' or 'function', name or '', arg)
+ lines[1] = ('%s%s %s(%s)'):format(
+ vm.isAsync(source) and 'async ' or '',
+ oop and 'method' or 'function',
+ name or '', arg
+ )
lines[2] = rtn
return table.concat(lines, '\n')
end
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 54fab5fc..404adb44 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -1724,3 +1724,11 @@ local function <?f?>() end
function f()
-> nil
]]
+
+TEST [[
+---@async
+local function <?f?>() end
+]]
+[[
+async function f()
+]]