aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/lsp')
-rw-r--r--runtime/lua/vim/lsp/buf.lua19
-rw-r--r--runtime/lua/vim/lsp/handlers.lua2
-rw-r--r--runtime/lua/vim/lsp/util.lua2
3 files changed, 16 insertions, 7 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index bcfaecdfcc..fa8ee23805 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -408,13 +408,13 @@ function M.rename(new_name, options)
local cword = vfn.expand('<cword>')
---@private
- local function get_text_at_range(range)
+ local function get_text_at_range(range, offset_encoding)
return vim.api.nvim_buf_get_text(
bufnr,
range.start.line,
- range.start.character,
+ util._get_line_byte_from_position(bufnr, range.start, offset_encoding),
range['end'].line,
- range['end'].character,
+ util._get_line_byte_from_position(bufnr, range['end'], offset_encoding),
{}
)[1]
end
@@ -461,9 +461,9 @@ function M.rename(new_name, options)
if result.placeholder then
prompt_opts.default = result.placeholder
elseif result.start then
- prompt_opts.default = get_text_at_range(result)
+ prompt_opts.default = get_text_at_range(result, client.offset_encoding)
elseif result.range then
- prompt_opts.default = get_text_at_range(result.range)
+ prompt_opts.default = get_text_at_range(result.range, client.offset_encoding)
else
prompt_opts.default = cword
end
@@ -752,7 +752,14 @@ local function on_code_action_results(results, ctx, options)
enriched_ctx.client_id = client.id
fn(command, enriched_ctx)
else
- M.execute_command(command)
+ -- Not using command directly to exclude extra properties,
+ -- see https://github.com/python-lsp/python-lsp-server/issues/146
+ local params = {
+ command = command.command,
+ arguments = command.arguments,
+ workDoneToken = command.workDoneToken,
+ }
+ client.request('workspace/executeCommand', params, nil, ctx.bufnr)
end
end
end
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 61cc89dcac..935f4b64f8 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -40,10 +40,12 @@ local function progress_handler(_, result, ctx, _)
if val.kind == 'begin' then
client.messages.progress[token] = {
title = val.title,
+ cancellable = val.cancellable,
message = val.message,
percentage = val.percentage,
}
elseif val.kind == 'report' then
+ client.messages.progress[token].cancellable = val.cancellable
client.messages.progress[token].message = val.message
client.messages.progress[token].percentage = val.percentage
elseif val.kind == 'end' then
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 63e9342b1a..b041385c9c 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1038,8 +1038,8 @@ function M.jump_to_location(location, offset_encoding, reuse_win)
if win then
api.nvim_set_current_win(win)
else
- api.nvim_set_current_buf(bufnr)
api.nvim_buf_set_option(bufnr, 'buflisted', true)
+ api.nvim_set_current_buf(bufnr)
end
local range = location.range or location.targetSelectionRange
local row = range.start.line