mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Fix rename support.
This commit is contained in:
		| @@ -44,6 +44,7 @@ local function request(method, params, callback) | |||||||
|     callback = {callback, 'f'}; |     callback = {callback, 'f'}; | ||||||
|   } |   } | ||||||
|   return vim.lsp.buf_request(0, method, params, function(err, _, result, client_id) |   return vim.lsp.buf_request(0, method, params, function(err, _, result, client_id) | ||||||
|  |     local _ = log.debug() and log.debug("vim.lsp.buf", method, client_id, err, result) | ||||||
|     if err then error(tostring(err)) end |     if err then error(tostring(err)) end | ||||||
|     return callback(err, method, result, client_id) |     return callback(err, method, result, client_id) | ||||||
|   end) |   end) | ||||||
|   | |||||||
| @@ -52,16 +52,12 @@ function M.text_document_apply_text_edit(text_edit, bufnr) | |||||||
|     api.nvim_buf_set_lines(bufnr, start.line, finish.line, false, new_lines) |     api.nvim_buf_set_lines(bufnr, start.line, finish.line, false, new_lines) | ||||||
|     return |     return | ||||||
|   end |   end | ||||||
|   api.nvim_err_writeln('apply_text_edit currently only supports character ranges starting at 0') |  local lines = api.nvim_buf_get_lines(bufnr, start.line, finish.line + 1, false) | ||||||
|   error('apply_text_edit currently only supports character ranges starting at 0') |  local suffix = lines[#lines]:sub(finish.character+1) | ||||||
|   return |  local prefix = lines[1]:sub(1, start.character) | ||||||
|   --  TODO test and finish this support for character ranges. |  new_lines[#new_lines] = new_lines[#new_lines]..suffix | ||||||
| --  local lines = api.nvim_buf_get_lines(0, start.line, finish.line + 1, false) |  new_lines[1] = prefix..new_lines[1] | ||||||
| --  local suffix = lines[#lines]:sub(finish.character+2) |  api.nvim_buf_set_lines(bufnr, start.line, finish.line + 1, false, new_lines) | ||||||
| --  local prefix = lines[1]:sub(start.character+2) |  | ||||||
| --  new_lines[#new_lines] = new_lines[#new_lines]..suffix |  | ||||||
| --  new_lines[1] = prefix..new_lines[1] |  | ||||||
| --  api.nvim_buf_set_lines(0, start.line, finish.line, false, new_lines) |  | ||||||
| end | end | ||||||
|  |  | ||||||
| -- textDocument/completion response returns one of CompletionItem[], CompletionList or null. | -- textDocument/completion response returns one of CompletionItem[], CompletionList or null. | ||||||
| @@ -158,18 +154,15 @@ function M.workspace_apply_workspace_edit(workspace_edit) | |||||||
|     return |     return | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   if workspace_edit.changes == nil or #workspace_edit.changes == 0 then |   local all_changes = workspace_edit.changes | ||||||
|  |   if not (all_changes and not vim.tbl_isempty(all_changes)) then | ||||||
|     return |     return | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   for uri, changes in pairs(workspace_edit.changes) do |   for uri, changes in pairs(all_changes) do | ||||||
|     local fname = vim.uri_to_fname(uri) |     local bufnr = vim.uri_to_bufnr(uri) | ||||||
|     -- TODO improve this approach. Try to edit open buffers without switching. |  | ||||||
|     -- Not sure how to handle files which aren't open. This is deprecated |  | ||||||
|     -- anyway, so I guess it could be left as is. |  | ||||||
|     api.nvim_command('edit '..fname) |  | ||||||
|     for _, change in ipairs(changes) do |     for _, change in ipairs(changes) do | ||||||
|       M.text_document_apply_text_edit(change) |       M.text_document_apply_text_edit(change, bufnr) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ashkan Kiani
					Ashkan Kiani