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/initialized.lua | |
parent | 0583236680b16588c52c7c98ac5a3f8a7071b868 (diff) | |
download | lua-language-server-9dc816f99f4a4329a3daff55a7199a8265a00c2c.zip |
Support multiple workspace folders
Diffstat (limited to 'script/method/initialized.lua')
-rw-r--r-- | script/method/initialized.lua | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/script/method/initialized.lua b/script/method/initialized.lua index e4ab585b..9e37fb37 100644 --- a/script/method/initialized.lua +++ b/script/method/initialized.lua @@ -1,8 +1,37 @@ -local rpc = require 'rpc' -local workspace = require 'workspace' +local rpc = require 'rpc' + +--- @param lsp LSP +--- @return boolean +return function (lsp) + 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 -local function initAfterConfig(lsp) - -- 必须动态注册的事件: rpc:request('client/registerCapability', { registrations = { -- 监视文件变化 @@ -27,32 +56,6 @@ local function initAfterConfig(lsp) }, function () log.debug('client/registerCapability Success!') end) -end -return function (lsp) - local uri = lsp.workspace and lsp.workspace.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], - }) - initAfterConfig(lsp) - end) return true end |