summaryrefslogtreecommitdiff
path: root/script/method/initialized.lua
diff options
context:
space:
mode:
authorRuin0x11 <ipickering2@gmail.com>2020-05-25 19:16:45 -0700
committerRuin0x11 <ipickering2@gmail.com>2020-05-25 19:25:36 -0700
commit9dc816f99f4a4329a3daff55a7199a8265a00c2c (patch)
treed400a9cb6f1a897913ff9fe56d7d0e83c45c078b /script/method/initialized.lua
parent0583236680b16588c52c7c98ac5a3f8a7071b868 (diff)
downloadlua-language-server-9dc816f99f4a4329a3daff55a7199a8265a00c2c.zip
Support multiple workspace folders
Diffstat (limited to 'script/method/initialized.lua')
-rw-r--r--script/method/initialized.lua63
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