summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/method/initialized.lua33
-rw-r--r--server/src/method/workspace/didChangeConfiguration.lua2
-rw-r--r--server/src/workspace.lua1
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