mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(lsp): add bufnr to formatting requests
Add the buffer number to the `textDocument/formatting` request, so that it is passed to the handler. The built-in formatting handlers do not use the buffer number, but user overrides should have access to it.
This commit is contained in:
		| @@ -156,7 +156,7 @@ function M.formatting(options) | |||||||
|   if client == nil then return end |   if client == nil then return end | ||||||
|  |  | ||||||
|   local params = util.make_formatting_params(options) |   local params = util.make_formatting_params(options) | ||||||
|   return client.request("textDocument/formatting", params) |   return client.request("textDocument/formatting", params, nil, vim.api.nvim_get_current_buf()) | ||||||
| end | end | ||||||
|  |  | ||||||
| --- Performs |vim.lsp.buf.formatting()| synchronously. | --- Performs |vim.lsp.buf.formatting()| synchronously. | ||||||
| @@ -176,7 +176,7 @@ function M.formatting_sync(options, timeout_ms) | |||||||
|   if client == nil then return end |   if client == nil then return end | ||||||
|  |  | ||||||
|   local params = util.make_formatting_params(options) |   local params = util.make_formatting_params(options) | ||||||
|   local result, err = client.request_sync("textDocument/formatting", params, timeout_ms) |   local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf()) | ||||||
|   if result and result.result then |   if result and result.result then | ||||||
|     util.apply_text_edits(result.result) |     util.apply_text_edits(result.result) | ||||||
|   elseif err then |   elseif err then | ||||||
| @@ -218,7 +218,7 @@ function M.formatting_seq_sync(options, timeout_ms, order) | |||||||
|   for _, client in ipairs(clients) do |   for _, client in ipairs(clients) do | ||||||
|     if client.resolved_capabilities.document_formatting then |     if client.resolved_capabilities.document_formatting then | ||||||
|       local params = util.make_formatting_params(options) |       local params = util.make_formatting_params(options) | ||||||
|       local result, err = client.request_sync("textDocument/formatting", params, timeout_ms) |       local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf()) | ||||||
|       if result and result.result then |       if result and result.result then | ||||||
|         util.apply_text_edits(result.result) |         util.apply_text_edits(result.result) | ||||||
|       elseif err then |       elseif err then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lukas Reineke
					Lukas Reineke