summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/hover/function.lua17
-rw-r--r--server/test/crossfile/hover.lua19
2 files changed, 35 insertions, 1 deletions
diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua
index 5adeeb7e..6139bd1b 100644
--- a/server/src/core/hover/function.lua
+++ b/server/src/core/hover/function.lua
@@ -184,7 +184,22 @@ local function getComment(func)
if not func then
return nil
end
- return func:getComment()
+ local comments = {}
+ local params = func:getEmmyParams()
+ if params then
+ for _, param in ipairs(params) do
+ local option = param:getOption()
+ if option and option.comment then
+ comments[#comments+1] = ('+ `%s`*(%s)*: %s'):format(param:getName(), param:getType(), option.comment)
+ end
+ end
+ end
+ comments[#comments+1] = '\n'
+ comments[#comments+1] = func:getComment()
+ if #comments == 0 then
+ return nil
+ end
+ return table.concat(comments, '\n')
end
local function getOverLoads(name, func, object, select)
diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua
index 19e8912f..f104fa38 100644
--- a/server/test/crossfile/hover.lua
+++ b/server/test/crossfile/hover.lua
@@ -310,3 +310,22 @@ x: option
|>'选项2' -- 注释2]]
}
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = '',
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ ---@param x string {comment = 'aaaa'}
+ ---@param y string {comment = 'bbbb'}
+ local function <?f?>(x, y) end
+ ]]
+ },
+ hover = {
+ label = 'function f(x: string, y: string)',
+ name = 'f',
+ }
+}