diff options
-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 | ||||
-rw-r--r-- | script-beta/provider/init.lua | 4 | ||||
-rw-r--r-- | test-beta/completion/init.lua | 1 |
5 files changed, 25 insertions, 21 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 diff --git a/script-beta/provider/init.lua b/script-beta/provider/init.lua index 985ec6be..67af9bb0 100644 --- a/script-beta/provider/init.lua +++ b/script-beta/provider/init.lua @@ -344,8 +344,8 @@ proto.on('completionItem/resolve', function (item) end local resolved = core.resolve(id) item.detail = resolved.detail - item.documentation = resolved.documentation and { - value = resolved.documentation, + item.documentation = resolved.description and { + value = resolved.description, kind = 'markdown', } return item diff --git a/test-beta/completion/init.lua b/test-beta/completion/init.lua index 228c4e78..e6f740c4 100644 --- a/test-beta/completion/init.lua +++ b/test-beta/completion/init.lua @@ -41,6 +41,7 @@ function TEST(script) files.setText('', new_script) local result = core.completion('', pos) for _, item in ipairs(result) do + core.resolve(item.id) for k in pairs(item) do if k ~= 'label' and k ~= 'kind' then item[k] = nil |