summaryrefslogtreecommitdiff
path: root/script-beta/core/hover
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-18 17:06:34 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-18 17:06:34 +0800
commitab27e9a9d62b00a779712fbb7bddd9f2910707a2 (patch)
treedc82a7a1bc252d82748e413b5f8b4243d7bcd085 /script-beta/core/hover
parent8b060037c9fd5961f8de6b9da674d5a29a77334e (diff)
downloadlua-language-server-ab27e9a9d62b00a779712fbb7bddd9f2910707a2.zip
可选参数尽量写在变量名后面,与其他语言保持一致
Diffstat (limited to 'script-beta/core/hover')
-rw-r--r--script-beta/core/hover/arg.lua12
-rw-r--r--script-beta/core/hover/return.lua17
2 files changed, 18 insertions, 11 deletions
diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua
index 2b7d47d3..4ea2cafe 100644
--- a/script-beta/core/hover/arg.lua
+++ b/script-beta/core/hover/arg.lua
@@ -77,10 +77,10 @@ local function asFunction(source, oop)
local arg = source.args[i]
local name = arg.name or guide.getName(arg)
if name then
- args[i] = ('%s: %s%s'):format(
+ args[i] = ('%s%s: %s'):format(
name,
- vm.getInferType(arg),
- optionalArg(arg) and '?' or ''
+ optionalArg(arg) and '?' or '',
+ vm.getInferType(arg)
)
else
args[i] = ('%s'):format(vm.getInferType(arg))
@@ -106,10 +106,10 @@ local function asDocFunction(source)
for i = 1, #source.args do
local arg = source.args[i]
local name = arg.name[1]
- args[i] = ('%s: %s%s'):format(
+ args[i] = ('%s%s: %s'):format(
name,
- vm.getInferType(arg.extends),
- arg.optional and '?' or ''
+ arg.optional and '?' or '',
+ vm.getInferType(arg.extends)
)
end
return table.concat(args, ', ')
diff --git a/script-beta/core/hover/return.lua b/script-beta/core/hover/return.lua
index a6058133..c6406395 100644
--- a/script-beta/core/hover/return.lua
+++ b/script-beta/core/hover/return.lua
@@ -108,11 +108,18 @@ local function asFunction(source)
end
if #types > 0 or rtn[1] then
local tp = mergeTypes(types) or 'any'
- line[#line+1] = ('%s%s%s'):format(
- rtn[1].name and (rtn[1].name[1] .. ': ') or '',
- tp,
- rtn[1].optional and '?' or ''
- )
+ if rtn[1].name then
+ line[#line+1] = ('%s%s: %s'):format(
+ rtn[1].name[1],
+ rtn[1].optional and '?' or '',
+ tp
+ )
+ else
+ line[#line+1] = ('%s%s'):format(
+ tp,
+ rtn[1].optional and '?' or ''
+ )
+ end
else
break
end