diff options
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/completion.lua | 19 | ||||
-rw-r--r-- | script-beta/core/hover/description.lua | 9 | ||||
-rw-r--r-- | script-beta/core/hover/init.lua | 13 |
3 files changed, 22 insertions, 19 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 13b5998e..51020a48 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -7,6 +7,7 @@ local library = require 'library' local getLabel = require 'core.hover.label' local getName = require 'core.hover.name' local getArg = require 'core.hover.arg' +local getDesc = require 'core.hover.description' local config = require 'config' local util = require 'utility' @@ -124,16 +125,6 @@ local function buildFunction(results, source, oop, data) end end -local function buildDesc(source) - if source.description then - return source.description - end - local lib = vm.getLibrary(source) - if lib then - return lib.description - end -end - local function checkLocal(ast, word, offset, results) local locals = guide.getVisibleLocals(ast.ast, offset) for name, source in pairs(locals) do @@ -145,7 +136,7 @@ local function checkLocal(ast, word, offset, results) id = stack(function () return { detail = getLabel(source), - description = buildDesc(source), + description = getDesc(source), } end), }) @@ -156,7 +147,7 @@ local function checkLocal(ast, word, offset, results) id = stack(function () return { detail = getLabel(source), - description = buildDesc(source), + description = getDesc(source), } end), } @@ -201,7 +192,7 @@ local function checkField(word, start, parent, oop, results) id = stack(function () return { detail = getLabel(info.source), - description = buildDesc(info.source), + description = getDesc(info.source), } end), }) @@ -220,7 +211,7 @@ local function checkField(word, start, parent, oop, results) id = stack(function () return { detail = getLabel(info.source), - description = buildDesc(info.source), + description = getDesc(info.source), } end) } diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua index ae33e133..e84fc3f3 100644 --- a/script-beta/core/hover/description.lua +++ b/script-beta/core/hover/description.lua @@ -39,8 +39,17 @@ local function asString(source) end end +local function tryLibrary(source) + local lib = vm.getLibrary(source) + if not lib then + return + end + return lib.description +end + return function (source) if source.type == 'string' then return asString(source) end + return tryLibrary(source) end diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua index 47d4c5a6..b2b99e2f 100644 --- a/script-beta/core/hover/init.lua +++ b/script-beta/core/hover/init.lua @@ -7,6 +7,7 @@ local util = require 'utility' local function getHoverAsFunction(source) local values = vm.getValue(source) + local desc = getDesc(source) local labels = {} local defs = 0 local protos = 0 @@ -29,8 +30,9 @@ local function getHoverAsFunction(source) if defs == 1 and other == 0 then return { - label = next(labels), - source = source, + label = next(labels), + source = source, + description = desc, } end @@ -51,8 +53,9 @@ local function getHoverAsFunction(source) end local label = table.concat(lines, '\n') return { - label = label, - source = source, + label = label, + source = source, + description = desc, } end @@ -64,8 +67,8 @@ local function getHoverAsValue(source) local desc = getDesc(source) return { label = label, - description = desc, source = source, + description = desc, } end |