From 034d28c705ccb93dea27613cbf91ba3f9c1caaa7 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Tue, 12 Jul 2022 03:37:01 +0200 Subject: 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. --- runtime/lua/vim/lsp.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 554b5f0bfa..29b077e3c0 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -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 -- cgit