summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/completion.lua11
-rw-r--r--server/test/completion/init.lua22
2 files changed, 28 insertions, 5 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index e2db64d9..5c86aa7e 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -167,20 +167,21 @@ local function buildSnipArgs(args, enums)
return table.concat(t, ', ')
end
-local function getFunctionSnip(name, value)
+local function getFunctionSnip(name, value, source)
if value:getType() ~= 'function' then
return
end
local lib = value:getLib()
+ local object = source:get 'object'
local hover
if lib then
- hover = getFunctionHoverAsLib(name, lib)
+ hover = getFunctionHoverAsLib(name, lib, object)
else
local emmy = value:getEmmy()
if emmy and emmy.type == 'emmy.functionType' then
- hover = getFunctionHoverAsEmmy(name, emmy)
+ hover = getFunctionHoverAsEmmy(name, emmy, object)
else
- hover = getFunctionHover(name, value:getFunction())
+ hover = getFunctionHover(name, value:getFunction(), object)
end
end
if not hover then
@@ -197,7 +198,7 @@ local function getValueData(cata, name, value, pos, source)
documentation = getDucumentation(name, value),
detail = getDetail(value),
kind = getKind(cata, value),
- snip = getFunctionSnip(name, value),
+ snip = getFunctionSnip(name, value, source),
}
if cata == 'field' then
if not parser:grammar(name, 'Name') then
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 4f2b3b8f..12600e58 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -886,6 +886,28 @@ xpcal$
}
TEST [[
+function mt:f(a, b, c)
+end
+
+mt:f$
+]]
+{
+ {
+ label = 'f',
+ kind = CompletionItemKind.Method,
+ documentation = EXISTS,
+ detail = EXISTS,
+ },
+ {
+ label = 'f()',
+ kind = CompletionItemKind.Snippet,
+ documentation = EXISTS,
+ detail = EXISTS,
+ insertText = 'f(${1:a: any}, ${2:b: any}, ${3:c: any})',
+ },
+}
+
+TEST [[
---@$
]]
(EXISTS)