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
This commit is contained in:
Lewis Russell
2024-02-11 12:37:20 +00:00
committed by GitHub
parent 8e86193502
commit ed1b66bd99
5 changed files with 357 additions and 432 deletions

View File

@@ -139,30 +139,6 @@ describe('LSP', function()
end)
end)
end)
describe('lsp._cmd_parts test', function()
local function _cmd_parts(input)
return exec_lua(
[[
lsp = require('vim.lsp')
return lsp._cmd_parts(...)
]],
input
)
end
it('should valid cmd argument', function()
eq(true, pcall(_cmd_parts, { 'nvim' }))
eq(true, pcall(_cmd_parts, { 'nvim', '--head' }))
end)
it('should invalid cmd argument', function()
eq('.../lsp.lua:0: cmd: expected list, got nvim', pcall_err(_cmd_parts, 'nvim'))
eq(
'.../lsp.lua:0: cmd argument: expected string, got number',
pcall_err(_cmd_parts, { 'nvim', 1 })
)
end)
end)
end)
describe('LSP', function()