diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-03 14:00:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-03 14:00:56 +0800 |
commit | d24683a456cba86e7aea614df0f73b06205064c7 (patch) | |
tree | b63cf8bf6299b70616037b4fd1f802b898286ff0 | |
parent | 8315f15e5316ed0e1d95df5d957a3e95bf3c131f (diff) | |
download | lua-language-server-d24683a456cba86e7aea614df0f73b06205064c7.zip |
可以忽略指定目录
-rw-r--r-- | .vscode/settings.json | 3 | ||||
-rw-r--r-- | package.json | 6 | ||||
-rw-r--r-- | server/src/config.lua | 3 | ||||
-rw-r--r-- | server/src/workspace.lua | 19 |
4 files changed, 30 insertions, 1 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5d7f3703 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "Lua.workspace.ignoreDir": ["publish"] +} diff --git a/package.json b/package.json index 20315f75..aa0bab0f 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,12 @@ "type": "array", "items": "string", "description": "Defined global variables.\n已定义的全局变量。" + }, + "Lua.workspace.ignoreDir": { + "scope": "resource", + "type": "array", + "items": "string", + "description": "Ignored directories.\n忽略的目录。" } } } 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 |