summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-16 15:11:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-16 15:11:05 +0800
commit6e0beb5d81db4691e86295a64bb2f66c50f29036 (patch)
treec899b4385ab8cad50d0968d292cefca789e1155b /script-beta
parentefdd1a9b98c4129b1c1b45a2086fb25b63c1bf0b (diff)
downloadlua-language-server-6e0beb5d81db4691e86295a64bb2f66c50f29036.zip
特殊处理定义为doc.meta的文件
Diffstat (limited to 'script-beta')
-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
4 files changed, 48 insertions, 7 deletions
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