diff options
-rw-r--r-- | .vscode/settings.json | 9 | ||||
-rw-r--r-- | package.json | 6 | ||||
-rw-r--r-- | server/src/config.lua | 7 | ||||
-rw-r--r-- | server/src/workspace.lua | 16 |
4 files changed, 31 insertions, 7 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 6ae13d7d..5eb8b111 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,10 @@ { "Lua.workspace.ignoreDir": [ - "publish", - "3rd" + "publish" ], - "Lua.diagnostics.globals": ["TEST", "ERR", "OUT"] + "Lua.diagnostics.globals": [ + "TEST", + "ERR", + "OUT" + ] } diff --git a/package.json b/package.json index 986ddf4c..86178bd7 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,12 @@ "type": "array", "items": "string", "description": "Ignored directories.\n忽略的目录。" + }, + "Lua.workspace.ignoreSubmodules": { + "scope": "resource", + "type": "boolean", + "default": true, + "description": "Ignore submodules.\n忽略子模块。" } } } diff --git a/server/src/config.lua b/server/src/config.lua index a19f17d8..449a6002 100644 --- a/server/src/config.lua +++ b/server/src/config.lua @@ -29,11 +29,12 @@ end local Template = { diagnostics = { - globals = {{}, Str2Hash ';'}, - disable = {{}, Str2Hash ';'}, + globals = {{}, Str2Hash ';'}, + disable = {{}, Str2Hash ';'}, }, workspace = { - ignoreDir = {{}, Str2Hash ';'} + ignoreDir = {{}, Str2Hash ';'}, + ignoreSubmodules= {true, Boolean}, } } diff --git a/server/src/workspace.lua b/server/src/workspace.lua index 2fd7ad65..6e7faaaf 100644 --- a/server/src/workspace.lua +++ b/server/src/workspace.lua @@ -78,9 +78,23 @@ function mt:init(rootUri) log.info('Log path: ', logPath) log.init(ROOT, logPath) + local ignored = {} + for path in pairs(config.config.workspace.ignoreDir) do + ignored[path] = true + end + if config.config.workspace.ignoreSubmodules then + local buf = io.load(ROOT:parent_path() / '.gitmodules') + if buf then + for path in buf:gmatch('path = ([^\r\n]+)') do + log.debug('忽略子模块:', path) + ignored[path] = true + end + end + end + async.run('scanfiles', { root = self.root:string(), - ignore = config.config.workspace.ignoreDir, + ignore = ignored, }, function (file) if file == 'ok' then self:reset() |