From fc9a50fe317d936152b0c1dd26ee436fde281b39 Mon Sep 17 00:00:00 2001 From: sumneko Date: Fri, 12 Apr 2019 11:01:54 +0800 Subject: =?UTF-8?q?#14=20=E5=B7=A5=E4=BD=9C=E5=8C=BA=E6=9C=89=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E5=AD=90=E7=9B=AE=E5=BD=95=E6=97=B6=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=AC=AC=E4=B8=80=E4=B8=AA=E7=9B=AE=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/method/initialized.lua | 33 ++++++++++++++-------- .../method/workspace/didChangeConfiguration.lua | 2 ++ 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 -- cgit v1.2.3