diff options
author | Nicolas Hillegeer <nicolas@hillegeer.com> | 2022-07-12 03:37:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 19:37:01 -0600 |
commit | 034d28c705ccb93dea27613cbf91ba3f9c1caaa7 (patch) | |
tree | d02221008c7502397e19460782f3ba225511cc63 /runtime/lua/vim/lsp.lua | |
parent | 195d8496a03bf5a14f5d114d57d841b037d543c4 (diff) | |
download | rneovim-034d28c705ccb93dea27613cbf91ba3f9c1caaa7.tar.gz rneovim-034d28c705ccb93dea27613cbf91ba3f9c1caaa7.tar.bz2 rneovim-034d28c705ccb93dea27613cbf91ba3f9c1caaa7.zip |
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.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 3 |
1 files changed, 3 insertions, 0 deletions
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 |