diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-19 20:44:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-19 20:44:25 +0800 |
commit | 875785763b635786449d32b0062c832efc6d5084 (patch) | |
tree | 369770d93771e6be2e505989a66c8068236235db | |
parent | 39af624faa6909ea16f1815e819915c6b95d3bd5 (diff) | |
download | lua-language-server-875785763b635786449d32b0062c832efc6d5084.zip |
new setting `Lua.workspace.userThirdParty`
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/config/config.lua | 1 | ||||
-rw-r--r-- | script/library.lua | 30 |
3 files changed, 24 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md index 74b6fedd..eb9d74d4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # changelog ## 2.3.1 +* `NEW` setting `Lua.workspace.userThirdParty`, * `CHG` path in config supports `~/xxxx` * `FIX` [#606](https://github.com/sumneko/lua-language-server/issues/606) * `FIX` [#607](https://github.com/sumneko/lua-language-server/issues/607) diff --git a/script/config/config.lua b/script/config/config.lua index 1b023c04..e9b29e6b 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -173,6 +173,7 @@ local Template = { ['Lua.workspace.preloadFileSize'] = Type.Integer >> 100, ['Lua.workspace.library'] = Type.Hash(Type.String, Type.Boolean, ';'), ['Lua.workspace.checkThirdParty'] = Type.Boolean >> true, + ['Lua.workspace.userThirdParty'] = Type.Array(Type.String), ['Lua.completion.enable'] = Type.Boolean >> true, ['Lua.completion.callSnippet'] = Type.String >> 'Disable', ['Lua.completion.keywordSnippet'] = Type.String >> 'Replace', diff --git a/script/library.lua b/script/library.lua index 0ec6c954..5772105a 100644 --- a/script/library.lua +++ b/script/library.lua @@ -281,18 +281,32 @@ local function loadSingle3rdConfig(libraryDir) return cfg end -local function load3rdConfig() - local thirdDir = ROOT / 'meta' / '3rd' - if not fs.is_directory(thirdDir) then +local innerThirdDir = ROOT / 'meta' / '3rd' + +local function load3rdConfigInDir(dir, configs, inner) + if not fs.is_directory(dir) then return end - local configs = {} - for libraryDir in thirdDir:list_directory() do + for libraryDir in dir:list_directory() do local suc, res = xpcall(loadSingle3rdConfig, log.error, libraryDir) - if suc then + if suc and res then + if inner then + res.dirname = ('${3rd}/%s'):format(res.name) + else + res.dirname = ('%s/%s'):format(dir:string(), res.name) + end configs[#configs+1] = res end end +end + +local function load3rdConfig() + local configs = {} + load3rdConfigInDir(innerThirdDir, configs, true) + local thirdDirs = config.get 'Lua.workspace.userThirdParty' + for _, thirdDir in ipairs(thirdDirs) do + load3rdConfigInDir(fs.path(thirdDir), configs) + end return configs end @@ -306,14 +320,14 @@ local function apply3rd(cfg, onlyMemory) changes[#changes+1] = { key = 'Lua.runtime.plugin', action = 'set', - value = ('${3rd}/%s/plugin.lua'):format(cfg.name), + value = ('%s/plugin.lua'):format(cfg.dirname), } end changes[#changes+1] = { key = 'Lua.workspace.library', action = 'add', - value = ('${3rd}/%s/library'):format(cfg.name), + value = ('%s/library'):format(cfg.dirname), } client.setConfig(changes, onlyMemory) |