diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-25 14:18:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-25 14:18:02 +0800 |
commit | b8a2374374cb242ddb196195e8578c6eff8b0558 (patch) | |
tree | 6ae36318bedd1471e7056ffedcdd371aee421cf3 /script | |
parent | b5e42716d41fac42b715fe0358f77d446713e2d3 (diff) | |
download | lua-language-server-b8a2374374cb242ddb196195e8578c6eff8b0558.zip |
#166 不再重复请求工作目录
Diffstat (limited to 'script')
-rw-r--r-- | script/method/initialized.lua | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/script/method/initialized.lua b/script/method/initialized.lua index d84a2159..e4ab585b 100644 --- a/script/method/initialized.lua +++ b/script/method/initialized.lua @@ -1,11 +1,7 @@ local rpc = require 'rpc' local workspace = require 'workspace' -local function initAfterConfig(lsp, firstScope) - if firstScope then - lsp.workspace = workspace(lsp, firstScope.name) - lsp.workspace:init(firstScope.uri) - end +local function initAfterConfig(lsp) -- 必须动态注册的事件: rpc:request('client/registerCapability', { registrations = { @@ -34,36 +30,29 @@ local function initAfterConfig(lsp, firstScope) end return function (lsp) - -- 请求工作目录 - rpc:request('workspace/workspaceFolders', nil, function (folders) - local firstScope - if folders then - firstScope = folders[1] - end - local uri = firstScope and firstScope.uri - -- 请求配置 - rpc:request('workspace/configuration', { - items = { - { - scopeUri = uri, - section = 'Lua', - }, - { - scopeUri = uri, - section = 'files.associations', - }, - { - scopeUri = uri, - section = 'files.exclude', - } + local uri = lsp.workspace and lsp.workspace.uri + -- 请求配置 + rpc:request('workspace/configuration', { + items = { + { + scopeUri = uri, + section = 'Lua', }, - }, function (configs) - lsp:onUpdateConfig(configs[1], { - associations = configs[2], - exclude = configs[3], - }) - initAfterConfig(lsp, firstScope) - end) + { + 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 |