summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-03 14:00:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-03 14:00:56 +0800
commitd24683a456cba86e7aea614df0f73b06205064c7 (patch)
treeb63cf8bf6299b70616037b4fd1f802b898286ff0 /server/src
parent8315f15e5316ed0e1d95df5d957a3e95bf3c131f (diff)
downloadlua-language-server-d24683a456cba86e7aea614df0f73b06205064c7.zip
可以忽略指定目录
Diffstat (limited to 'server/src')
-rw-r--r--server/src/config.lua3
-rw-r--r--server/src/workspace.lua19
2 files changed, 21 insertions, 1 deletions
diff --git a/server/src/config.lua b/server/src/config.lua
index c69df6ad..aa8452c6 100644
--- a/server/src/config.lua
+++ b/server/src/config.lua
@@ -32,6 +32,9 @@ local Template = {
postSpcae = {true, Boolean},
spaceOnlyLine = {true, Boolean},
globals = {{}, Str2Hash ';'},
+ },
+ workspace = {
+ ignoreDir = {{}, Str2Hash ';'}
}
}
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index aaa9a47d..ad88848a 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -1,5 +1,6 @@
local fs = require 'bee.filesystem'
local async = require 'async'
+local config = require 'config'
local function split(str, sep)
local t = {}
@@ -91,10 +92,26 @@ function mt:init(rootUri)
ROOT = self.root:string()
}, function (list)
log.info(('Found [%d] files'):format(#list))
+ local ignored = {}
+ for name in pairs(config.config.workspace.ignoreDir) do
+ local path = fs.absolute(self.root / name)
+ local str = path:string():lower()
+ ignored[#ignored+1] = str
+ log.debug(str)
+ end
for _, filename in ipairs(list) do
local path = fs.absolute(fs.path(filename))
local name = path:string():lower()
- self.files[name] = self:uriEncode(path)
+ local ok = true
+ for _, ignore in ipairs(ignored) do
+ if name:sub(1, #ignore) == ignore then
+ ok = false
+ break
+ end
+ end
+ if ok then
+ self.files[name] = self:uriEncode(path)
+ end
end
self:reset()
self._complete = true