summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/hover.lua36
1 files changed, 20 insertions, 16 deletions
diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua
index 4d64647d..02671eed 100644
--- a/server/src/core/hover.lua
+++ b/server/src/core/hover.lua
@@ -281,21 +281,11 @@ local function buildValueReturns(func)
return '\n -> ' .. table.concat(strs, ', ')
end
-local function getFunctionHover(name, func, source, lib, oo, select)
- local args = ''
- local returns
- local enum
- local tip
- local argLabel
- if lib then
- args, argLabel = buildLibArgs(lib, oo, select)
- returns = buildLibReturns(lib)
- enum = buildEnum(lib)
- tip = lib.description
- else
- args, argLabel = buildValueArgs(func, source, select)
- returns = buildValueReturns(func)
- end
+local function getFunctionHoverAsLib(name, lib, oo, select)
+ local args, argLabel = buildLibArgs(lib, oo, select)
+ local returns = buildLibReturns(lib)
+ local enum = buildEnum(lib)
+ local tip = lib.description
local title = ('function %s(%s)%s'):format(name, args, returns)
return {
label = title,
@@ -305,6 +295,16 @@ local function getFunctionHover(name, func, source, lib, oo, select)
}
end
+local function getFunctionHover(name, func, source, select)
+ local args, argLabel = buildValueArgs(func, source, select)
+ local returns = buildValueReturns(func)
+ local title = ('function %s(%s)%s'):format(name, args, returns)
+ return {
+ label = title,
+ argLabel = argLabel,
+ }
+end
+
local function findClass(result)
-- 根据部分字段尝试找出自定义类型
local metatable = result.value.metatable
@@ -468,7 +468,11 @@ return function (result, source, lsp, select)
local name = fullKey or buildValueName(result, source)
local hover
if valueType == 'function' then
- hover = getFunctionHover(name, result.value, source, lib, oo, select)
+ if lib then
+ hover = getFunctionHoverAsLib(name, lib, oo, select)
+ else
+ hover = getFunctionHover(name, result.value, source, select)
+ end
else
hover = getValueHover(name, valueType, result, source, lib)
end