summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion.lua8
-rw-r--r--script/core/hover/description.lua32
-rw-r--r--script/core/hover/init.lua1
3 files changed, 29 insertions, 12 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index d65f4b3a..fe6ff2ef 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -245,12 +245,10 @@ local function buildDesc(source)
local hover = getHover.get(source)
local md = markdown()
md:add('lua', hover.label)
+ md:splitLine()
md:add('md', hover.description)
- local snip = getSnip(source)
- if snip then
- md:add('md', '-------------')
- md:add('lua', snip)
- end
+ md:splitLine()
+ md:add('lua', getSnip(source))
return md:string()
end
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 75c3ea9c..7c2af81f 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -104,6 +104,9 @@ local function getBindComment(source, docGroup, base)
break
else
continue = false
+ if doc.type == 'doc.field' then
+ lines = nil
+ end
end
end
if source.comment then
@@ -266,19 +269,33 @@ local function getFunctionComment(source)
return md:string()
end
+local function tryDocClassComment(source)
+ for _, def in ipairs(vm.getDefs(source, 0)) do
+ if def.type == 'doc.class.name' then
+ local class = guide.getDocState(def)
+ local comment = getBindComment(class, class.bindGroup, class)
+ if comment then
+ return comment
+ end
+ end
+ end
+ if source.bindDocs then
+ for _, doc in ipairs(source.bindDocs) do
+ if doc.type == 'doc.class' then
+ local comment = getBindComment(doc, source.bindDocs, doc)
+ return comment
+ end
+ end
+ end
+end
+
local function tryDocComment(source)
if not source.bindDocs then
return
end
if not isFunction(source) then
local comment = getBindComment(source, source.bindDocs)
- if not comment then
- return
- end
- local md = markdown()
- md:add('md', "---")
- md:add('md', comment)
- return md:string()
+ return comment
end
return getFunctionComment(source)
end
@@ -334,4 +351,5 @@ return function (source)
or tryDocFieldUpComment(source)
or tyrDocParamComment(source)
or tryDocComment(source)
+ or tryDocClassComment(source)
end
diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua
index 28aef3e6..80c4db1e 100644
--- a/script/core/hover/init.lua
+++ b/script/core/hover/init.lua
@@ -6,6 +6,7 @@ local getDesc = require 'core.hover.description'
local util = require 'utility'
local findSource = require 'core.find-source'
local lang = require 'language'
+local markdown = require 'provider.markdown'
local function eachFunctionAndOverload(value, callback)
callback(value)