From d24683a456cba86e7aea614df0f73b06205064c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 3 Jan 2019 14:00:56 +0800 Subject: =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=BF=BD=E7=95=A5=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +++ package.json | 6 ++++++ server/src/config.lua | 3 +++ server/src/workspace.lua | 19 ++++++++++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json 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 -- cgit v1.2.3