diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-26 01:31:45 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-26 01:31:45 +0800 |
commit | c78fbf09aa4406db905a8a0e6dd5731871f2c262 (patch) | |
tree | 50d1c7005f1ab879608a5738d626370e1a01ac70 /script/core/hover | |
parent | ed64703ef9fec2b1c6736a0deb68bd567875a654 (diff) | |
download | lua-language-server-c78fbf09aa4406db905a8a0e6dd5731871f2c262.zip |
#1207
return names and parentheses can be used in `DocFunction`
Diffstat (limited to 'script/core/hover')
-rw-r--r-- | script/core/hover/args.lua | 2 | ||||
-rw-r--r-- | script/core/hover/return.lua | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/script/core/hover/args.lua b/script/core/hover/args.lua index 21e7c00f..321fb081 100644 --- a/script/core/hover/args.lua +++ b/script/core/hover/args.lua @@ -32,7 +32,7 @@ local function asFunction(source) vm.getInfer(argNode):view(guide.getUri(source), 'any') ) elseif arg.type == '...' then - args[#args+1] = ('%s: %s'):format( + args[#args+1] = ('%s%s'):format( '...', vm.getInfer(arg):view(guide.getUri(source), 'any') ) diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua index 7f96b282..b496990b 100644 --- a/script/core/hover/return.lua +++ b/script/core/hover/return.lua @@ -63,7 +63,10 @@ local function asFunction(source) for i = 1, num do local rtn = vm.getReturnOfFunction(source, i) local doc = docs[i] - local name = doc and doc.name and doc.name[1] and (doc.name[1] .. ': ') + local name = doc and doc.name and doc.name[1] + if name and name ~= '...' then + name = name .. ': ' + end local text = rtn and ('%s%s'):format( name or '', vm.getInfer(rtn):view(guide.getUri(source)) @@ -85,6 +88,13 @@ local function asDocFunction(source) local returns = {} for i, rtn in ipairs(source.returns) do local rtnText = vm.getInfer(rtn):view(guide.getUri(source)) + if rtn.name then + if rtn.name[1] == '...' then + rtnText = rtn.name[1] .. rtnText + else + rtnText = rtn.name[1] .. ': ' .. rtnText + end + end if i == 1 then returns[#returns+1] = (' -> %s'):format(rtnText) else |