diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-21 16:26:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-21 16:26:13 +0800 |
commit | 6e447f52bb9cf25730115b3baa7989ff95273471 (patch) | |
tree | 9e6683871ef269554ee225b2c672b43a4afacf67 /server/src/core | |
parent | 49566afd015200c867f673dbe04f97dc241cc4be (diff) | |
download | lua-language-server-6e447f52bb9cf25730115b3baa7989ff95273471.zip |
#101 signature 额外显示完整的label
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/hover/emmy_function.lua | 6 | ||||
-rw-r--r-- | server/src/core/hover/function.lua | 6 | ||||
-rw-r--r-- | server/src/core/hover/lib_function.lua | 6 | ||||
-rw-r--r-- | server/src/core/signature.lua | 14 |
4 files changed, 19 insertions, 13 deletions
diff --git a/server/src/core/hover/emmy_function.lua b/server/src/core/hover/emmy_function.lua index 36fd4e90..e14e88c5 100644 --- a/server/src/core/hover/emmy_function.lua +++ b/server/src/core/hover/emmy_function.lua @@ -125,13 +125,15 @@ return function (name, emmy, object, select) local enum, rawEnum = buildEnum(emmy) local tip = emmy.description local headLen = #('function %s('):format(name) - local title = ('function %s(%s)%s'):format(name, argStr, returns) + 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, + label = title .. returns, + title = title, + returns = returns, description = tip, enum = enum, rawEnum = rawEnum, diff --git a/server/src/core/hover/function.lua b/server/src/core/hover/function.lua index df26cd40..25796d60 100644 --- a/server/src/core/hover/function.lua +++ b/server/src/core/hover/function.lua @@ -229,13 +229,15 @@ return function (name, func, object, select) local comment = getComment(func) local overloads = getOverLoads(name, func, object, select) local headLen = #('function %s('):format(name) - local title = ('function %s(%s)%s'):format(name, argStr, returns) + 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, + label = title .. returns, + title = title, + returns = returns, description = comment, enum = enum, rawEnum = rawEnum, diff --git a/server/src/core/hover/lib_function.lua b/server/src/core/hover/lib_function.lua index 09b1e47b..3c693961 100644 --- a/server/src/core/hover/lib_function.lua +++ b/server/src/core/hover/lib_function.lua @@ -208,13 +208,15 @@ return function (name, lib, object, select) local tip = lib.description local doc = buildDoc(lib) local headLen = #('function %s('):format(name) - local title = ('function %s(%s)%s'):format(name, argStr, returns) + 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, + label = title .. returns, + title = title, + returns = returns, description = tip, enum = enum, rawEnum = rawEnum, diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua index 62aa5b3c..3c9e696c 100644 --- a/server/src/core/signature.lua +++ b/server/src/core/signature.lua @@ -63,29 +63,29 @@ local function hovers(call, pos) local object = source:get 'object' local lib, fullkey = findLib(source) local name = fullkey or buildValueName(source) - local hovers = {} + local hover if lib then - hovers[#hovers+1] = getFunctionHoverAsLib(name, lib, object, select) + hover = getFunctionHoverAsLib(name, lib, object, select) else local emmy = value:getEmmy() if emmy and emmy.type == 'emmy.functionType' then - hovers[#hovers+1] = getFunctionHoverAsEmmy(name, emmy, object, select) + hover = getFunctionHoverAsEmmy(name, emmy, object, select) else ---@type emmyFunction local func = value:getFunction() - hovers[#hovers+1] = getFunctionHover(name, func, object, select) + hover = getFunctionHover(name, func, object, select) local overLoads = func and func:getEmmyOverLoads() if overLoads then for _, ol in ipairs(overLoads) do - hovers[#hovers+1] = getFunctionHoverAsEmmy(name, ol, object, select) + hover = getFunctionHoverAsEmmy(name, ol, object, select) end end end end - if #hovers == 0 then + if not hover then return nil end - return hovers + return { hover } end local function isInFunctionOrTable(call, pos) |