diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-02-11 12:37:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-11 12:37:20 +0000 |
commit | ed1b66bd998b98ee8cf76b5a23c323352588dd56 (patch) | |
tree | c262796dcab8a9dd22dbf7acd611366d38d43900 /runtime/lua/vim/lsp/rpc.lua | |
parent | 8e86193502608c4a833f6996b942e8dd0eb8e476 (diff) | |
download | rneovim-ed1b66bd998b98ee8cf76b5a23c323352588dd56.tar.gz rneovim-ed1b66bd998b98ee8cf76b5a23c323352588dd56.tar.bz2 rneovim-ed1b66bd998b98ee8cf76b5a23c323352588dd56.zip |
refactor(lsp): move more code to client.lua
The dispatchers used by the RPC client should be defined in the client,
so they have been moved there. Due to this, it also made sense to move
all code related to client configuration and the creation of the RPC
client there too.
Now vim.lsp.start_client is significantly simplified and now mostly
contains logic for tracking open clients.
- Renamed client.new -> client.start
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 23f70826e5..e849bb4f2a 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -732,8 +732,7 @@ end --- interact with it. Communication with the spawned process happens via stdio. For --- communication via TCP, spawn a process manually and use |vim.lsp.rpc.connect()| --- ----@param cmd string Command to start the LSP server. ----@param cmd_args string[] List of additional string arguments to pass to {cmd}. +---@param cmd string[] Command to start the LSP server. --- ---@param dispatchers? vim.lsp.rpc.Dispatchers Dispatchers for LSP message types. --- Valid dispatcher names are: @@ -754,12 +753,11 @@ end --- - `request()` |vim.lsp.rpc.request()| --- - `is_closing()` returns a boolean indicating if the RPC is closing. --- - `terminate()` terminates the RPC client. -function M.start(cmd, cmd_args, dispatchers, extra_spawn_params) - log.info('Starting RPC client', { cmd = cmd, args = cmd_args, extra = extra_spawn_params }) +function M.start(cmd, dispatchers, extra_spawn_params) + log.info('Starting RPC client', { cmd = cmd, extra = extra_spawn_params }) validate({ - cmd = { cmd, 's' }, - cmd_args = { cmd_args, 't' }, + cmd = { cmd, 't' }, dispatchers = { dispatchers, 't', true }, }) @@ -795,7 +793,7 @@ function M.start(cmd, cmd_args, dispatchers, extra_spawn_params) local stderr_handler = function(_, chunk) if chunk then - log.error('rpc', cmd, 'stderr', chunk) + log.error('rpc', cmd[1], 'stderr', chunk) end end @@ -804,10 +802,7 @@ function M.start(cmd, cmd_args, dispatchers, extra_spawn_params) detached = extra_spawn_params.detached end - local cmd1 = { cmd } - vim.list_extend(cmd1, cmd_args) - - local ok, sysobj_or_err = pcall(vim.system, cmd1, { + local ok, sysobj_or_err = pcall(vim.system, cmd, { stdin = true, stdout = stdout_handler, stderr = stderr_handler, |