summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-21 21:42:06 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-21 21:42:06 +0800
commit079847053a3020600a9fd0c35e12a9f7e8d57f16 (patch)
treea991917bef281a4ecab8356634c678292ea13128 /server/src/core
parent736373ad83a7505aa2f088c889c45a518695e571 (diff)
downloadlua-language-server-079847053a3020600a9fd0c35e12a9f7e8d57f16.zip
简化 signature
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/hover/emmy_function.lua11
-rw-r--r--server/src/core/hover/function.lua11
-rw-r--r--server/src/core/hover/lib_function.lua11
-rw-r--r--server/src/core/signature.lua22
4 files changed, 24 insertions, 31 deletions
diff --git a/server/src/core/hover/emmy_function.lua b/server/src/core/hover/emmy_function.lua
index e14e88c5..37b44a79 100644
--- a/server/src/core/hover/emmy_function.lua
+++ b/server/src/core/hover/emmy_function.lua
@@ -124,15 +124,10 @@ return function (name, emmy, object, select)
local returns = buildEmmyReturns(emmy)
local enum, rawEnum = buildEnum(emmy)
local tip = emmy.description
- local headLen = #('function %s('):format(name)
- local title = ('function %s(%s)'):format(name, argStr)
- if argLabel then
- argLabel[1] = argLabel[1] + headLen
- argLabel[2] = argLabel[2] + headLen
- end
return {
- label = title .. returns,
- title = title,
+ label = ('function %s(%s)%s'):format(name, argStr, returns),
+ name = name,
+ argStr = argStr,
returns = returns,
description = tip,
enum = enum,
diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua
index 25796d60..8796be57 100644
--- a/server/src/core/hover/function.lua
+++ b/server/src/core/hover/function.lua
@@ -228,15 +228,10 @@ return function (name, func, object, select)
local enum, rawEnum = buildEnum(func)
local comment = getComment(func)
local overloads = getOverLoads(name, func, object, select)
- local headLen = #('function %s('):format(name)
- local title = ('function %s(%s)'):format(name, argStr)
- if argLabel then
- argLabel[1] = argLabel[1] + headLen
- argLabel[2] = argLabel[2] + headLen
- end
return {
- label = title .. returns,
- title = title,
+ label = ('function %s(%s)%s'):format(name, argStr, returns),
+ name = name,
+ argStr = argStr,
returns = returns,
description = comment,
enum = enum,
diff --git a/server/src/core/hover/lib_function.lua b/server/src/core/hover/lib_function.lua
index 3c693961..bd9cddaa 100644
--- a/server/src/core/hover/lib_function.lua
+++ b/server/src/core/hover/lib_function.lua
@@ -207,15 +207,10 @@ return function (name, lib, object, select)
local enum, rawEnum = buildEnum(lib)
local tip = lib.description
local doc = buildDoc(lib)
- local headLen = #('function %s('):format(name)
- local title = ('function %s(%s)'):format(name, argStr)
- if argLabel then
- argLabel[1] = argLabel[1] + headLen
- argLabel[2] = argLabel[2] + headLen
- end
return {
- label = title .. returns,
- title = title,
+ label = ('function %s(%s)%s'):format(name, argStr, returns),
+ name = name,
+ argStr = argStr,
returns = returns,
description = tip,
enum = enum,
diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua
index 3c9e696c..bbe35ffa 100644
--- a/server/src/core/signature.lua
+++ b/server/src/core/signature.lua
@@ -47,7 +47,7 @@ local function getFunctionSource(call)
return nil
end
-local function hovers(call, pos)
+local function getHover(call, pos)
local args = call:bindCall()
if not args then
return nil
@@ -82,10 +82,7 @@ local function hovers(call, pos)
end
end
end
- if not hover then
- return nil
- end
- return { hover }
+ return hover
end
local function isInFunctionOrTable(call, pos)
@@ -119,7 +116,18 @@ return function (vm, pos)
return nil
end
- local hovers = hovers(nearCall, pos)
+ local hover = getHover(nearCall, pos)
+ if not hover then
+ return nil
+ end
- return hovers
+ -- skip `name(`
+ local head = #hover.name + 1
+ hover.label = ('%s(%s)'):format(hover.name, hover.argStr)
+ if hover.argLabel then
+ hover.argLabel[1] = hover.argLabel[1] + head
+ hover.argLabel[2] = hover.argLabel[2] + head
+ end
+
+ return { hover }
end