diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-08-23 10:18:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-08-23 10:18:01 +0800 |
commit | 3cadf4b8ba6b7bc128ebaf1e408dedf531e2db93 (patch) | |
tree | 68ce56d5274c1c4d2659e1af337ea24e69f8cbd0 /script | |
parent | cb1a412bc7c205c73aec3ef2b1f8f8baf4564fb0 (diff) | |
download | lua-language-server-3cadf4b8ba6b7bc128ebaf1e408dedf531e2db93.zip |
resolve #352
Diffstat (limited to 'script')
-rw-r--r-- | script/core/completion.lua | 6 | ||||
-rw-r--r-- | script/core/hover/init.lua | 28 |
2 files changed, 22 insertions, 12 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index dc4ddf28..98e388c3 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -190,8 +190,12 @@ local function buildDesc(source) if source.type == 'dummy' then return end + local desc = markdown() local hover = getHover.get(source) - return hover + desc:add('md', hover) + desc:splitLine() + desc:add('lua', getSnip(source)) + return desc end local function buildFunction(results, source, value, oop, data) diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua index 6e98d6c9..cf0da19d 100644 --- a/script/core/hover/init.lua +++ b/script/core/hover/init.lua @@ -13,21 +13,22 @@ local function getHover(source) local labelMark = {} local descMark = {} - local function addHover(def) + local function addHover(def, checkLable) if defMark[def] then return end defMark[def] = true - local label = getLabel(def) - local desc = getDesc(def) - - if not labelMark[tostring(label)] then - labelMark[tostring(label)] = true - md:add('lua', label) - md:splitLine() + if checkLable then + local label = getLabel(def) + if not labelMark[tostring(label)] then + labelMark[tostring(label)] = true + md:add('lua', label) + md:splitLine() + end end + local desc = getDesc(def) if not descMark[tostring(desc)] then descMark[tostring(desc)] = true md:add('md', desc) @@ -39,13 +40,18 @@ local function getHover(source) for _, def in ipairs(vm.getDefs(source)) do if def.type == 'function' or def.type == 'doc.type.function' then - addHover(def) + addHover(def, true) end end else - addHover(source) + addHover(source, true) for _, def in ipairs(vm.getDefs(source)) do - addHover(def) + local isFunction + if def.type == 'function' + or def.type == 'doc.type.function' then + isFunction = true + end + addHover(def, isFunction) end end |