diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-12 11:01:54 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-12 11:01:54 +0800 |
commit | fc9a50fe317d936152b0c1dd26ee436fde281b39 (patch) | |
tree | f6c0b95c6b2fb187a5ee77c073354d0eeea22e34 | |
parent | 438ce75dcae7d022314a68eeafc176502dbbc4b4 (diff) | |
download | lua-language-server-fc9a50fe317d936152b0c1dd26ee436fde281b39.zip |
#14 工作区有多个子目录时,使用第一个目录的配置
-rw-r--r-- | server/src/method/initialized.lua | 33 | ||||
-rw-r--r-- | server/src/method/workspace/didChangeConfiguration.lua | 2 | ||||
-rw-r--r-- | server/src/workspace.lua | 1 |
3 files changed, 25 insertions, 11 deletions
diff --git a/server/src/method/initialized.lua b/server/src/method/initialized.lua index 97cafe82..cf86427d 100644 --- a/server/src/method/initialized.lua +++ b/server/src/method/initialized.lua @@ -1,8 +1,11 @@ local rpc = require 'rpc' local workspace = require 'workspace' -local config = require 'config' -local function initAfterConfig(lsp) +local function initAfterConfig(lsp, firstScope) + if firstScope then + lsp.workspace = workspace(lsp, firstScope.name) + lsp.workspace:init(firstScope.uri) + end -- 请求工作目录 rpc:request('workspace/workspaceFolders', nil, function (folders) if folders then @@ -41,16 +44,24 @@ local function initAfterConfig(lsp) end return function (lsp) - -- 请求配置 - rpc:request('workspace/configuration', { - items = { - { - section = 'Lua', + -- 请求工作目录 + rpc:request('workspace/workspaceFolders', nil, function (folders) + local firstScope + if folders then + firstScope = folders[1] + end + -- 请求配置 + rpc:request('workspace/configuration', { + items = { + { + scopeUri = firstScope and firstScope.uri, + section = 'Lua', + }, }, - }, - }, function (configs) - lsp:onUpdateConfig(configs[1]) - initAfterConfig(lsp) + }, function (configs) + lsp:onUpdateConfig(configs[1]) + initAfterConfig(lsp, firstScope) + end) end) return true end diff --git a/server/src/method/workspace/didChangeConfiguration.lua b/server/src/method/workspace/didChangeConfiguration.lua index 58fc0079..732d28dd 100644 --- a/server/src/method/workspace/didChangeConfiguration.lua +++ b/server/src/method/workspace/didChangeConfiguration.lua @@ -1,10 +1,12 @@ local rpc = require 'rpc' return function (lsp) + local uri = lsp.workspace and lsp.workspace.uri -- 请求配置 rpc:request('workspace/configuration', { items = { { + scopeUri = uri, section = 'Lua', }, }, diff --git a/server/src/workspace.lua b/server/src/workspace.lua index 01532c7a..b30edce6 100644 --- a/server/src/workspace.lua +++ b/server/src/workspace.lua @@ -134,6 +134,7 @@ end function mt:init(rootUri) self.root = self:uriDecode(rootUri) + self.uri = rootUri if not self.root then return end |