mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	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
					Nicolas Hillegeer
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							195d8496a0
						
					
				
				
					commit
					034d28c705
				
			| @@ -746,6 +746,9 @@ function lsp.start(config, opts) | |||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   local client_id = lsp.start_client(config) |   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) |   lsp.buf_attach_client(bufnr, client_id) | ||||||
|   return client_id |   return client_id | ||||||
| end | end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user