summaryrefslogtreecommitdiff
path: root/server/src/core/hover_function.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/core/hover_function.lua')
-rw-r--r--server/src/core/hover_function.lua35
1 files changed, 32 insertions, 3 deletions
diff --git a/server/src/core/hover_function.lua b/server/src/core/hover_function.lua
index 4573bcc2..42a5f766 100644
--- a/server/src/core/hover_function.lua
+++ b/server/src/core/hover_function.lua
@@ -12,7 +12,6 @@ local function buildValueArgs(func, oo, select)
end
end
local strs = {}
- local argLabel
local start = 1
if oo then
start = 2
@@ -27,21 +26,46 @@ local function buildValueArgs(func, oo, select)
max = math.max(#names, #values)
end
for i = start, max do
+ if i > start then
+ strs[#strs+1] = ', '
+ end
local name = names[i]
local value = values[i] or 'any'
+ if i == select then
+ strs[#strs+1] = '@ARG'
+ end
if name then
strs[#strs+1] = name .. ': ' .. value
else
strs[#strs+1] = value
end
if i == select then
- argLabel = strs[#strs]
+ strs[#strs+1] = '@ARG'
end
end
if func.hasDots then
+ if max > 0 then
+ strs[#strs+1] = ', '
+ end
strs[#strs+1] = '...'
end
- return table.concat(strs, ', '), argLabel
+ local text = table.concat(strs)
+ local argLabel = {}
+ for i = 1, 2 do
+ local pos = text:find('@ARG', 1, true)
+ if pos then
+ if i == 1 then
+ argLabel[i] = pos
+ else
+ argLabel[i] = pos - 1
+ end
+ text = text:sub(1, pos-1) .. text:sub(pos+4)
+ end
+ end
+ if #argLabel == 0 then
+ argLabel = nil
+ end
+ return text, argLabel
end
local function buildValueReturns(func)
@@ -63,7 +87,12 @@ end
return function (name, func, oo, select)
local args, argLabel = buildValueArgs(func, oo, select)
local returns = buildValueReturns(func)
+ local headLen = #('function %s('):format(name)
local title = ('function %s(%s)%s'):format(name, args, returns)
+ if argLabel then
+ argLabel[1] = argLabel[1] + headLen
+ argLabel[2] = argLabel[2] + headLen
+ end
return {
label = title,
argLabel = argLabel,