summaryrefslogtreecommitdiff
path: root/script/workspace
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-04 11:10:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-04 11:10:55 +0800
commit83975e739d6ed07fee0bf64f7cbf0be00d5afcc7 (patch)
tree65047896839cb4b1831a1df1b83048d5d7a9c452 /script/workspace
parent50a1df60f0916ff2a1cd68a37d501851b10d1da3 (diff)
downloadlua-language-server-83975e739d6ed07fee0bf64f7cbf0be00d5afcc7.zip
workspace: supports `.dll`(`.so`) in `require`
Diffstat (limited to 'script/workspace')
-rw-r--r--script/workspace/workspace.lua75
1 files changed, 48 insertions, 27 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index de96b569..57bdc00f 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -172,36 +172,48 @@ end
local function loadFileFactory(root, progress, isLibrary)
return function (path)
local uri = furi.encode(path)
- if not files.isLua(uri) then
- return
- end
- if not isLibrary and progress.preload >= config.config.workspace.maxPreload then
- if not m.hasHitMaxPreload then
- m.hasHitMaxPreload = true
- proto.notify('window/showMessage', {
- type = 3,
- message = lang.script('MWS_MAX_PRELOAD', config.config.workspace.maxPreload),
- })
+ if files.isLua(uri) then
+ if not isLibrary and progress.preload >= config.config.workspace.maxPreload then
+ if not m.hasHitMaxPreload then
+ m.hasHitMaxPreload = true
+ proto.notify('window/showMessage', {
+ type = 3,
+ message = lang.script('MWS_MAX_PRELOAD', config.config.workspace.maxPreload),
+ })
+ end
+ return
end
- return
- end
- if not isLibrary then
- progress.preload = progress.preload + 1
+ if not isLibrary then
+ progress.preload = progress.preload + 1
+ end
+ progress.max = progress.max + 1
+ pub.task('loadFile', uri, function (text)
+ progress.read = progress.read + 1
+ if text then
+ log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #text / 1000.0))
+ if isLibrary then
+ log.info('++++As library of:', root)
+ files.setLibraryPath(uri, root)
+ end
+ files.setText(uri, text)
+ else
+ files.remove(uri)
+ end
+ end)
end
- progress.max = progress.max + 1
- pub.task('loadFile', uri, function (text)
- progress.read = progress.read + 1
- if text then
- log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #text / 1000.0))
- if isLibrary then
- log.info('++++As library of:', root)
- files.setLibraryPath(uri, root)
+ if files.isDll(uri) then
+ progress.max = progress.max + 1
+ pub.task('loadFile', uri, function (content)
+ progress.read = progress.read + 1
+ if content then
+ log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #content / 1000.0))
+ if isLibrary then
+ log.info('++++As library of:', root)
+ end
+ files.saveDll(uri, content)
end
- files.setText(uri, text)
- else
- files.remove(uri)
- end
- end)
+ end)
+ end
end
end
@@ -316,6 +328,15 @@ function m.findUrisByRequirePath(path)
local results = {}
local mark = {}
local searchers = {}
+ for uri in files.eachDll() do
+ local opens = files.getDllOpens(uri) or {}
+ for _, open in ipairs(opens) do
+ if open == path then
+ results[#results+1] = uri
+ end
+ end
+ end
+
local input = path:gsub('%.', '/')
:gsub('%%', '%%%%')
for _, luapath in ipairs(config.config.runtime.path) do