From d119c1cefff8a6a2812ac10375297f033a8cf5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 6 Dec 2018 17:12:47 +0800 Subject: =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=80=E4=B8=8B=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/hover.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'server/src') diff --git a/server/src/matcher/hover.lua b/server/src/matcher/hover.lua index 09d2f168..2b78216a 100644 --- a/server/src/matcher/hover.lua +++ b/server/src/matcher/hover.lua @@ -13,11 +13,12 @@ local function buildArgs(lib) if i > 1 then strs[#strs+1] = ', ' end - strs[#strs+1] = rtn.name or ('arg' .. tostring(i)) - strs[#strs+1] = ':' - strs[#strs+1] = rtn.type or 'any' + strs[#strs+1] = ('%s:%s'):format( + rtn.name or ('arg' .. tostring(i)), + (rtn.type or 'any') + ) if rtn.default then - strs[#strs+1] = (':%q'):format(rtn.default) + strs[#strs+1] = ('(%q)'):format(rtn.default) end if rtn.optional then strs[#strs+1] = ']' @@ -38,11 +39,12 @@ local function buildReturns(lib) if i > 1 then strs[#strs+1] = ', ' end - strs[#strs+1] = rtn.name or ('res' .. tostring(i)) - strs[#strs+1] = ':' - strs[#strs+1] = rtn.type or 'any' + strs[#strs+1] = ('%s:%s'):format( + rtn.name or ('res' .. tostring(i)), + (rtn.type or 'any') + ) if rtn.default then - strs[#strs+1] = (':%q'):format(rtn.default) + strs[#strs+1] = ('(%q)'):format(rtn.default) end if rtn.optional then strs[#strs+1] = ']' @@ -52,9 +54,9 @@ local function buildReturns(lib) end local function buildFunctionHover(lib, name) - local title = ('```lua\n%s(%s)%s\n```'):format(name, buildArgs(lib), buildReturns(lib)) + local title = ('function %s(%s)%s'):format(name, buildArgs(lib), buildReturns(lib)) local tip = lib.description or '' - return ('%s\n\n%s'):format(title, tip) + return ('```lua\n%s\n```\n%s'):format(title, tip) end return function (results, pos) -- cgit v1.2.3