summaryrefslogtreecommitdiff
path: root/script/method
diff options
context:
space:
mode:
authorTimur Celik <mail@timurcelik.de>2020-03-05 11:34:22 +0100
committerTimur Celik <mail@timurcelik.de>2020-03-05 11:42:19 +0100
commitf928a83509b19092bf57d838c8f441d9fd221c1d (patch)
tree8e0c07d3611ae306e614bf4442241d58d0f7a724 /script/method
parentad3baf56bf8e4e44491449fd87c1ad3b79746de1 (diff)
downloadlua-language-server-f928a83509b19092bf57d838c8f441d9fd221c1d.zip
Create first workspace based on client's rootUri
Currently the server will send a workspace/workspaceFolders request and use the first folder that is reported as workspace root. This doesn't work with clients that don't support workspaceFolders capability. The rootUri field of the response to 'initialize' is mandatory and can be used to create the initial workspace too. This patch does exactly this.
Diffstat (limited to 'script/method')
-rw-r--r--script/method/initialize.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/script/method/initialize.lua b/script/method/initialize.lua
index bc35a32b..1fb0cb5f 100644
--- a/script/method/initialize.lua
+++ b/script/method/initialize.lua
@@ -1,3 +1,5 @@
+local workspace = require 'workspace'
+
local function allWords()
local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[,#*@| ]]
local list = {}
@@ -7,8 +9,14 @@ local function allWords()
return list
end
-return function (lsp)
+return function (lsp, params)
lsp._inited = true
+
+ if params.rootUri then
+ lsp.workspace = workspace(lsp, 'root')
+ lsp.workspace:init(params.rootUri)
+ end
+
return {
capabilities = {
completionProvider = {