summaryrefslogtreecommitdiff
path: root/server/src/workspace.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-28 17:43:40 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-28 17:43:40 +0800
commitc427477428c0c1d583f42c0e7784684b8f713a6e (patch)
tree6944c9dbb52ac02e26a5a1df39451187d6ee260e /server/src/workspace.lua
parent4418abe11364b4ebf7dc205bb27811b8c7197b88 (diff)
downloadlua-language-server-c427477428c0c1d583f42c0e7784684b8f713a6e.zip
使用新的过滤器
Diffstat (limited to 'server/src/workspace.lua')
-rw-r--r--server/src/workspace.lua32
1 files changed, 20 insertions, 12 deletions
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index 348208ca..034a057c 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -78,16 +78,18 @@ function mt:init(rootUri)
log.info('Log path: ', logPath)
log.init(ROOT, logPath)
- local ignored = {}
+ local ignored = {
+ ['.git'] = true,
+ }
for path in pairs(config.config.workspace.ignoreDir) do
- ignored[path] = true
+ ignored[#ignored+1] = path
end
if config.config.workspace.ignoreSubmodules then
local buf = io.load(self.root / '.gitmodules')
if buf then
for path in buf:gmatch('path = ([^\r\n]+)') do
log.debug('忽略子模块:', path)
- ignored[path] = true
+ ignored[#ignored+1] = path
end
end
end
@@ -95,25 +97,31 @@ function mt:init(rootUri)
local buf = io.load(self.root / '.gitignore')
if buf then
for line in buf:gmatch '[^\r\n]+' do
- ignored[line] = true
+ ignored[#ignored+1] = line
end
end
end
+ log.debug('忽略文件:\r\n' .. table.concat(ignored, '\r\n'))
+
async.run('scanfiles', {
root = self.root:string(),
- ignore = ignored,
- }, function (file)
- if file == 'ok' then
+ ignored = ignored,
+ }, function (mode, ...)
+ if mode == 'ok' then
self:reset()
self._complete = true
return true
+ elseif mode == 'log' then
+ log.debug(...)
+ elseif mode == 'file' then
+ local file = ...
+ local path = fs.path(file.path)
+ local name = path:string():lower()
+ local uri = self:uriEncode(path)
+ self.files[name] = uri
+ self.lsp:readText(uri, path, file.buf)
end
- local path = fs.path(file.path)
- local name = path:string():lower()
- local uri = self:uriEncode(path)
- self.files[name] = uri
- self.lsp:readText(uri, path, file.buf)
end)
end