summaryrefslogtreecommitdiff
path: root/server/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/core')
-rw-r--r--server/src/core/completion.lua3
-rw-r--r--server/src/core/hover/lib_function.lua24
-rw-r--r--server/src/core/library.lua8
3 files changed, 32 insertions, 3 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index c192535d..3c6d9057 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -69,7 +69,8 @@ local function getDucumentation(name, value)
```lua
%s
```
-]]):format(hover.label or '', hover.description or '', hover.enum or '')
+%s
+]]):format(hover.label or '', hover.description or '', hover.enum or '', hover.doc or '')
return {
kind = 'markdown',
value = text,
diff --git a/server/src/core/hover/lib_function.lua b/server/src/core/hover/lib_function.lua
index c3caea7a..56e6e22f 100644
--- a/server/src/core/hover/lib_function.lua
+++ b/server/src/core/hover/lib_function.lua
@@ -1,4 +1,5 @@
-
+local lang = require 'language'
+local config = require 'config'
local function buildLibArgs(lib, object, select)
if not lib.args then
return ''
@@ -171,11 +172,31 @@ local function buildEnum(lib)
return table.concat(strs)
end
+local function buildDoc(lib)
+ local doc = lib.doc
+ if not doc then
+ return
+ end
+ local version = config.config.runtime.version
+ if version == 'Lua 5.1' then
+ return lang.script('HOVER_DOCUMENT_LUA51', doc)
+ elseif version == 'Lua 5.2' then
+ return lang.script('HOVER_DOCUMENT_LUA52', doc)
+ elseif version == 'Lua 5.3' then
+ return lang.script('HOVER_DOCUMENT_LUA53', doc)
+ elseif version == 'Lua 5.4' then
+ return lang.script('HOVER_DOCUMENT_LUA54', doc)
+ elseif version == 'LuaJIT' then
+ return lang.script('HOVER_DOCUMENT_LUAJIT', doc)
+ end
+end
+
return function (name, lib, object, select)
local args, argLabel = buildLibArgs(lib, object, select)
local returns = buildLibReturns(lib)
local enum = buildEnum(lib)
local tip = lib.description
+ local doc = buildDoc(lib)
local headLen = #('function %s('):format(name)
local title = ('function %s(%s)%s'):format(name, args, returns)
if argLabel then
@@ -187,5 +208,6 @@ return function (name, lib, object, select)
description = tip,
enum = enum,
argLabel = argLabel,
+ doc = doc,
}
end
diff --git a/server/src/core/library.lua b/server/src/core/library.lua
index f0c292aa..d5edad66 100644
--- a/server/src/core/library.lua
+++ b/server/src/core/library.lua
@@ -88,6 +88,9 @@ local function insertGlobal(tbl, key, value)
if not isMatchVersion(value.version) then
return false
end
+ if not value.doc then
+ value.doc = key
+ end
tbl[key] = value
return true
end
@@ -175,6 +178,9 @@ local function insertChild(tbl, name, key, value)
if not isMatchVersion(value.version) then
return
end
+ if not value.doc then
+ value.doc = ('%s.%s'):format(name, key)
+ end
if not tbl[name] then
tbl[name] = {
type = name,
@@ -189,7 +195,7 @@ local function mergeParent(alllibs, name, lib, libName)
for _, parent in ipairs(lib.parent) do
if parent.type == 'global' then
if isEnableGlobal(libName) then
- insertChild(alllibs.global, parent.name, name, lib)
+ insertChild(alllibs.global, parent.name, name, lib)
end
elseif parent.type == 'library' then
insertChild(alllibs.library, parent.name, name, lib)