summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-11 12:42:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-11 12:42:32 +0800
commitcfe1bbb6c2461e85b19c4190bc63160f447acc75 (patch)
tree1de09e941a1b97a5b7fbb4e1001baed24f8e2f9e /script-beta/core
parent05de2e6caecc62c4c6e16ec5256fd98a07c88d03 (diff)
downloadlua-language-server-cfe1bbb6c2461e85b19c4190bc63160f447acc75.zip
修改自动完成的预览
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/completion.lua20
-rw-r--r--script-beta/core/hover/init.lua7
2 files changed, 21 insertions, 6 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 33824b79..5aa06e42 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -8,8 +8,10 @@ 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 getHover = require 'core.hover'
local config = require 'config'
local util = require 'utility'
+local markdown = require 'provider.markdown'
local stackID = 0
local stacks = {}
@@ -118,6 +120,14 @@ local function buildDetail(source)
return types
end
+local function buildDesc(source)
+ local hover = getHover.get(source)
+ local md = markdown()
+ md:add('lua', hover.label)
+ md:add('md', hover.description)
+ return md:string()
+end
+
local function buildFunction(results, source, oop, data)
local snipType = config.config.completion.callSnippet
if snipType == 'Disable' or snipType == 'Both' then
@@ -132,7 +142,7 @@ local function buildFunction(results, source, oop, data)
snipData.id = stack(function ()
return {
detail = buildDetail(source),
- description = getDesc(source),
+ description = buildDesc(source),
}
end)
results[#results+1] = snipData
@@ -150,7 +160,7 @@ local function checkLocal(ast, word, offset, results)
id = stack(function ()
return {
detail = buildDetail(source),
- description = getDesc(source),
+ description = buildDesc(source),
}
end),
})
@@ -161,7 +171,7 @@ local function checkLocal(ast, word, offset, results)
id = stack(function ()
return {
detail = buildDetail(source),
- description = getDesc(source),
+ description = buildDesc(source),
}
end),
}
@@ -206,7 +216,7 @@ local function checkField(word, start, parent, oop, results)
id = stack(function ()
return {
detail = buildDetail(info.source),
- description = getDesc(info.source),
+ description = buildDesc(info.source),
}
end),
})
@@ -225,7 +235,7 @@ local function checkField(word, start, parent, oop, results)
id = stack(function ()
return {
detail = buildDetail(info.source),
- description = getDesc(info.source),
+ description = buildDesc(info.source),
}
end)
}
diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua
index b2b99e2f..38f6fa88 100644
--- a/script-beta/core/hover/init.lua
+++ b/script-beta/core/hover/init.lua
@@ -81,7 +81,7 @@ local function getHover(source)
end
end
-return function (uri, offset)
+local function getHoverByUri(uri, offset)
local ast = files.getAst(uri)
if not ast then
return nil
@@ -100,3 +100,8 @@ return function (uri, offset)
end)
return hover
end
+
+return {
+ get = getHover,
+ byUri = getHoverByUri,
+}