fix(lsp): don't attach a client in lsp.start() if there is none (#19328)

vim.lsp.start_client() may fail (for example if the `cmd` is not
executable). It produces a nice error notification in this case. Passing
the `nil` value returned from an erroneous `vim.lsp.start_client()` call
into `vim.lsp.buf_attach_client()` causes a meaty param validate
exception message. Avoid this.
This commit is contained in:
Nicolas Hillegeer
2022-07-12 03:37:01 +02:00
committed by GitHub
parent 195d8496a0
commit 034d28c705

View File

@@ -746,6 +746,9 @@ function lsp.start(config, opts)
end
end
local client_id = lsp.start_client(config)
if client_id == nil then
return nil -- lsp.start_client will have printed an error
end
lsp.buf_attach_client(bufnr, client_id)
return client_id
end