summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/template/basic.lua2
-rw-r--r--meta/template/bit32.lua2
-rw-r--r--meta/template/builtin.lua2
-rw-r--r--meta/template/coroutine.lua2
-rw-r--r--meta/template/debug.lua2
-rw-r--r--meta/template/file.lua2
-rw-r--r--meta/template/io.lua2
-rw-r--r--meta/template/math.lua2
-rw-r--r--meta/template/os.lua2
-rw-r--r--meta/template/package.lua2
-rw-r--r--meta/template/string.lua2
-rw-r--r--meta/template/table.lua2
-rw-r--r--meta/template/utf8.lua2
-rw-r--r--script-beta/core/completion.lua19
-rw-r--r--script-beta/core/hover/description.lua4
-rw-r--r--script-beta/parser/luadoc.lua10
-rw-r--r--script-beta/vm/getDocs.lua22
17 files changed, 74 insertions, 7 deletions
diff --git a/meta/template/basic.lua b/meta/template/basic.lua
index c58d09b7..4b093b52 100644
--- a/meta/template/basic.lua
+++ b/meta/template/basic.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@type table
arg = {}
diff --git a/meta/template/bit32.lua b/meta/template/bit32.lua
index 7429d40b..636abf20 100644
--- a/meta/template/bit32.lua
+++ b/meta/template/bit32.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class bit32
bit32 = {}
diff --git a/meta/template/builtin.lua b/meta/template/builtin.lua
index cd0080e2..2b547d1d 100644
--- a/meta/template/builtin.lua
+++ b/meta/template/builtin.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class any
---@class nil: any
---@class boolean: any
diff --git a/meta/template/coroutine.lua b/meta/template/coroutine.lua
index e805e542..013b883f 100644
--- a/meta/template/coroutine.lua
+++ b/meta/template/coroutine.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class coroutine
coroutine = {}
diff --git a/meta/template/debug.lua b/meta/template/debug.lua
index 58835011..703b7967 100644
--- a/meta/template/debug.lua
+++ b/meta/template/debug.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class debug
debug = {}
diff --git a/meta/template/file.lua b/meta/template/file.lua
index f24c0a38..763ae3ed 100644
--- a/meta/template/file.lua
+++ b/meta/template/file.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class file
local file = {}
diff --git a/meta/template/io.lua b/meta/template/io.lua
index a2b97877..1576c2b6 100644
--- a/meta/template/io.lua
+++ b/meta/template/io.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class io
---@field stdin file
---@field stdout file
diff --git a/meta/template/math.lua b/meta/template/math.lua
index cf047976..39f2cbe7 100644
--- a/meta/template/math.lua
+++ b/meta/template/math.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class math
---@field huge number
---@field maxinteger integer
diff --git a/meta/template/os.lua b/meta/template/os.lua
index c8d9cd61..e2694372 100644
--- a/meta/template/os.lua
+++ b/meta/template/os.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class os
os = {}
diff --git a/meta/template/package.lua b/meta/template/package.lua
index 47d6bab7..a7be0599 100644
--- a/meta/template/package.lua
+++ b/meta/template/package.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class package
---@field conifg string
---@field cpath string
diff --git a/meta/template/string.lua b/meta/template/string.lua
index 7faf4b1d..54891666 100644
--- a/meta/template/string.lua
+++ b/meta/template/string.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class string
string = {}
diff --git a/meta/template/table.lua b/meta/template/table.lua
index 8629d1dd..c7621455 100644
--- a/meta/template/table.lua
+++ b/meta/template/table.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class table
table = {}
diff --git a/meta/template/utf8.lua b/meta/template/utf8.lua
index 23445ddd..4bcbed59 100644
--- a/meta/template/utf8.lua
+++ b/meta/template/utf8.lua
@@ -1,3 +1,5 @@
+---@meta
+
---@class utf8
utf8 = {}
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 1939025d..6c8d9040 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -692,11 +692,17 @@ local function checkUri(ast, text, offset, results)
}
}
end
- collect[info.expect][#collect[info.expect]+1] = ([=[* [%s](%s) %s]=]):format(
- path,
- uri,
- lang.script('HOVER_USE_LUA_PATH', info.searcher)
- )
+ if vm.isMetaFile(uri) then
+ collect[info.expect][#collect[info.expect]+1] = ([=[* [[meta]](%s)]=]):format(
+ uri
+ )
+ else
+ collect[info.expect][#collect[info.expect]+1] = ([=[* [%s](%s) %s]=]):format(
+ path,
+ uri,
+ lang.script('HOVER_USE_LUA_PATH', info.searcher)
+ )
+ end
end
end
::CONTINUE::
@@ -1038,7 +1044,8 @@ local function tryLuaDocCate(line, results)
'generic',
'vararg',
'overload',
- 'deprecated'
+ 'deprecated',
+ 'meta',
} do
if matchKey(word, docType) then
results[#results+1] = {
diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua
index badeade7..7ba1ca52 100644
--- a/script-beta/core/hover/description.lua
+++ b/script-beta/core/hover/description.lua
@@ -34,7 +34,9 @@ local function asStringInRequire(source, literal)
path = path:sub(#ws.path + 1)
end
path = path:gsub('^[/\\]*', '')
- if searcher then
+ if vm.isMetaFile(uri) then
+ result[i] = ('* [[meta]](%s)'):format(uri)
+ elseif searcher then
searcher = searcher:sub(#ws.path + 1)
searcher = ws.normalize(searcher)
result[i] = ('* [%s](%s) %s'):format(path, uri, lang.script('HOVER_USE_LUA_PATH', searcher))
diff --git a/script-beta/parser/luadoc.lua b/script-beta/parser/luadoc.lua
index 94ddd37e..f88baa22 100644
--- a/script-beta/parser/luadoc.lua
+++ b/script-beta/parser/luadoc.lua
@@ -700,6 +700,14 @@ local function parseDeprecated()
}
end
+local function parseMeta()
+ return {
+ type = 'doc.meta',
+ start = getFinish(),
+ finish = getFinish(),
+ }
+end
+
local function convertTokens()
local tp, text = nextToken()
if not tp then
@@ -733,6 +741,8 @@ local function convertTokens()
return parseOverload()
elseif text == 'deprecated' then
return parseDeprecated()
+ elseif text == 'meta' then
+ return parseMeta()
end
end
diff --git a/script-beta/vm/getDocs.lua b/script-beta/vm/getDocs.lua
index 3fb0dfc0..75f74028 100644
--- a/script-beta/vm/getDocs.lua
+++ b/script-beta/vm/getDocs.lua
@@ -111,3 +111,25 @@ function vm.getDocTypes(name)
vm.getCache('getDocTypes')[name] = cache
return cache
end
+
+function vm.isMetaFile(uri)
+ local status = files.getAst(uri)
+ if not status then
+ return false
+ end
+ local cache = files.getCache(uri)
+ if cache.isMeta ~= nil then
+ return cache.isMeta
+ end
+ cache.isMeta = false
+ if not status.ast.docs then
+ return false
+ end
+ for _, doc in ipairs(status.ast.docs) do
+ if doc.type == 'doc.meta' then
+ cache.isMeta = true
+ return true
+ end
+ end
+ return false
+end