diff options
-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 | ||||
-rw-r--r-- | server/src/method/textDocument/signatureHelp.lua | 9 | ||||
-rw-r--r-- | server/test/crossfile/hover.lua | 14 |
6 files changed, 39 insertions, 16 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) diff --git a/server/src/method/textDocument/signatureHelp.lua b/server/src/method/textDocument/signatureHelp.lua index 6551464f..e898d32f 100644 --- a/server/src/method/textDocument/signatureHelp.lua +++ b/server/src/method/textDocument/signatureHelp.lua @@ -12,15 +12,18 @@ return function (lsp, params) return end - local description = hovers[1].description + local hover = hovers[1] + local desc = {} + desc[#desc+1] = '```lua\n' .. hover.label .. '\n```\n' + desc[#desc+1] = hover.description local active local signatures = {} for i, hover in ipairs(hovers) do local signature = { - label = hover.label, + label = hover.title, documentation = { kind = 'markdown', - value = description, + value = table.concat(desc, '\n'), }, } if hover.argLabel then diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua index 1d4328e1..dc6df615 100644 --- a/server/test/crossfile/hover.lua +++ b/server/test/crossfile/hover.lua @@ -123,6 +123,8 @@ TEST { label = 'function f(a: any, b: any)', name = 'f', args = EXISTS, + title = EXISTS, + returns = EXISTS, } } @@ -145,6 +147,8 @@ TEST { label = 'function (a: any, b: any)', name = '', args = EXISTS, + title = EXISTS, + returns = EXISTS, } } @@ -175,6 +179,8 @@ TEST { label = 'function mt:add(a: any, b: any)', name = 'mt:add', args = EXISTS, + title = EXISTS, + returns = EXISTS, }, } @@ -245,6 +251,8 @@ TEST { name = 'f', description = 'abc', args = EXISTS, + title = EXISTS, + returns = EXISTS, } } @@ -286,6 +294,8 @@ TEST { name = 'f', args = EXISTS, rawEnum = EXISTS, + title = EXISTS, + returns = EXISTS, enum = [[ x: string @@ -314,6 +324,8 @@ TEST { name = 'f', args = EXISTS, rawEnum = EXISTS, + title = EXISTS, + returns = EXISTS, enum = [[ x: option @@ -339,6 +351,8 @@ TEST { label = 'function f(x: string, y: string)', name = 'f', args = EXISTS, + title = EXISTS, + returns = EXISTS, description = [[ + `x`*(string)*: aaaa |