summaryrefslogtreecommitdiff
path: root/script-beta/core/completion.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-13 19:23:09 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-13 19:23:09 +0800
commitb22099c12e001bf81a6d1cf47655e6e815d04391 (patch)
tree79be562401816f70c831003ab6f7216b4c21350e /script-beta/core/completion.lua
parent2dacca7b19ba0162975c7f2da2dd5e9381b4a73c (diff)
downloadlua-language-server-b22099c12e001bf81a6d1cf47655e6e815d04391.zip
支持自动完成 dofile
Diffstat (limited to 'script-beta/core/completion.lua')
-rw-r--r--script-beta/core/completion.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index ec4b0fe6..2e32f515 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -512,7 +512,29 @@ local function checkUri(ast, text, offset, results)
end
elseif lib.name == 'dofile'
or lib.name == 'loadfile' then
- return workspace.findUrisByFilePath(literal, false)
+ for uri in files.eachFile() do
+ uri = files.getOriginUri(uri)
+ if files.eq(myUri, uri) then
+ goto CONTINUE
+ end
+ local path = workspace.getRelativePath(uri)
+ if matchKey(literal, path) then
+ if not collect[path] then
+ collect[path] = {
+ textEdit = {
+ start = source.start + #source[2],
+ finish = source.finish - #source[2],
+ }
+ }
+ end
+ -- TODO 翻译
+ collect[path][#collect[path]+1] = ([=[[%s](%s)]=]):format(
+ path,
+ uri
+ )
+ end
+ ::CONTINUE::
+ end
end
end)
for label, infos in util.sortPairs(collect) do