summaryrefslogtreecommitdiff
path: root/server/src/workspace.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/workspace.lua')
-rw-r--r--server/src/workspace.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index fecc9ab0..de1f417c 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -84,26 +84,35 @@ function mt:removeFile(uri)
end
function mt:searchPath(str)
+ if self.loaded[str] then
+ return self.loaded[str]
+ end
str = str:gsub('%.', '/')
local searchers = {}
for i, luapath in ipairs(self.luapath) do
searchers[i] = luapath:gsub('%?', str):lower()
end
- local results = {}
for filename, uri in pairs(self.files) do
for _, searcher in ipairs(searchers) do
if filename:sub(-#searcher) == searcher then
- results[#results+1] = uri
+ self.loaded[str] = uri
+ return uri
end
end
end
- return results[1]
+ return nil
+end
+
+function mt:reset()
+ self.laoded = {}
end
-return function (name, uri)
+return function (lsp, name, uri)
local workspace = setmetatable({
+ lsp = lsp,
name = name,
files = {},
+ loaded = {},
luapath = {
'?.lua',
'?/init.lua',