From c427477428c0c1d583f42c0e7784684b8f713a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 28 Jan 2019 17:43:40 +0800 Subject: =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=96=B0=E7=9A=84=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/workspace.lua | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'server/src/workspace.lua') 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 -- cgit v1.2.3