diff options
author | Ruin0x11 <ipickering2@gmail.com> | 2020-05-25 19:16:45 -0700 |
---|---|---|
committer | Ruin0x11 <ipickering2@gmail.com> | 2020-05-25 19:25:36 -0700 |
commit | 9dc816f99f4a4329a3daff55a7199a8265a00c2c (patch) | |
tree | d400a9cb6f1a897913ff9fe56d7d0e83c45c078b /script/method/workspace/didChangeWorkspaceFolders.lua | |
parent | 0583236680b16588c52c7c98ac5a3f8a7071b868 (diff) | |
download | lua-language-server-9dc816f99f4a4329a3daff55a7199a8265a00c2c.zip |
Support multiple workspace folders
Diffstat (limited to 'script/method/workspace/didChangeWorkspaceFolders.lua')
-rw-r--r-- | script/method/workspace/didChangeWorkspaceFolders.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/script/method/workspace/didChangeWorkspaceFolders.lua b/script/method/workspace/didChangeWorkspaceFolders.lua new file mode 100644 index 00000000..25c06f4b --- /dev/null +++ b/script/method/workspace/didChangeWorkspaceFolders.lua @@ -0,0 +1,43 @@ +local rpc = require 'rpc' + +--- @param lsp LSP +--- @param params table +return function (lsp, params) + local event = params.event + + for _, removed in ipairs(event.removed) do + lsp:removeWorkspace(removed.name, removed.uri) + end + + for _, added in ipairs(event.added) do + lsp:addWorkspace(added.name, added.uri) + end + + local ws = lsp.workspaces[1] + if ws then + -- 请求工作目录 + local uri = ws.uri + -- 请求配置 + rpc:request('workspace/configuration', { + items = { + { + scopeUri = uri, + section = 'Lua', + }, + { + scopeUri = uri, + section = 'files.associations', + }, + { + scopeUri = uri, + section = 'files.exclude', + } + }, + }, function (configs) + lsp:onUpdateConfig(configs[1], { + associations = configs[2], + exclude = configs[3], + }) + end) + end +end |