diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-28 16:19:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-28 16:19:03 +0800 |
commit | 1ce91bc1715601abc63404cd6e9e7f04b36d3aa7 (patch) | |
tree | 364104f32de48def773f96ce05bf0a64134202bd | |
parent | 8c35c44a9b25f104430936cb68f4daece468ec8a (diff) | |
download | lua-language-server-1ce91bc1715601abc63404cd6e9e7f04b36d3aa7.zip |
由客户端实现多工作目录支持
-rw-r--r-- | script/core/code_action.lua | 6 | ||||
-rw-r--r-- | script/method/initialize.lua | 8 | ||||
-rw-r--r-- | script/method/workspace/executeCommand.lua | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/script/core/code_action.lua b/script/core/code_action.lua index c9203f29..3e8f7582 100644 --- a/script/core/code_action.lua +++ b/script/core/code_action.lua @@ -1,5 +1,7 @@ local lang = require 'language' local library = require 'core.library' +local client = require 'client' +local sp = require 'bee.subprocess' local function disableDiagnostic(lsp, uri, data, callback) callback { @@ -124,7 +126,7 @@ local function solveTrailingSpace(lsp, uri, data, callback) kind = 'quickfix', command = { title = lang.script.COMMAND_REMOVE_SPACE, - command = 'lua.removeSpace', + command = 'lua.removeSpace:' .. sp:get_id(), arguments = { { uri = uri, @@ -160,7 +162,7 @@ local function solveAmbiguity1(lsp, uri, data, callback) kind = 'quickfix', command = { title = lang.script.COMMAND_ADD_BRACKETS, - command = 'lua.solve', + command = 'lua.solve:' .. sp:get_id(), arguments = { { name = 'ambiguity-1', diff --git a/script/method/initialize.lua b/script/method/initialize.lua index d11ed5e6..fe2888c8 100644 --- a/script/method/initialize.lua +++ b/script/method/initialize.lua @@ -2,6 +2,7 @@ local workspace = require 'workspace' local nonil = require 'without-check-nil' local client = require 'client' local json = require 'json' +local sp = require 'bee.subprocess' local function allWords() local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[,#*@| ]] @@ -20,10 +21,11 @@ return function (lsp, params) lsp.client = params client.init(params) log.info(table.dump(params)) + log.debug('ProcessID', sp.get_id()) if params.workspaceFolders and params.workspaceFolders ~= json.null then for _, folder in ipairs(params.workspaceFolders) do - lsp:addWorkspace(folder.name, folder.uri) + --lsp:addWorkspace(folder.name, folder.uri) end elseif params.rootUri and params.rootUri ~= json.null then lsp:addWorkspace('root', params.rootUri) @@ -61,8 +63,8 @@ return function (lsp, params) }, executeCommandProvider = { commands = { - 'lua.removeSpace', - 'lua.solve', + 'lua.removeSpace:' .. sp.get_id(), + 'lua.solve:' .. sp.get_id(), }, }, } diff --git a/script/method/workspace/executeCommand.lua b/script/method/workspace/executeCommand.lua index 57ca281d..2ad449e9 100644 --- a/script/method/workspace/executeCommand.lua +++ b/script/method/workspace/executeCommand.lua @@ -173,7 +173,7 @@ end --- @param lsp LSP --- @param params table return function (lsp, params) - local name = params.command + local name = params.command:gsub(':.+', '') if not command[name] then return end |