From 615efe666be25117199ec8c9d475b2ef86ac7015 Mon Sep 17 00:00:00 2001 From: Jan Steinke Date: Thu, 19 Aug 2021 19:11:22 +0200 Subject: [PATCH] Allow range parameters on command parser (#1123) --- lua/telescope/builtin/lsp.lua | 2 +- lua/telescope/command.lua | 8 ++++++-- plugin/telescope.vim | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua index 8ca8b92..bcbb833 100644 --- a/lua/telescope/builtin/lsp.lua +++ b/lua/telescope/builtin/lsp.lua @@ -256,7 +256,7 @@ lsp.code_actions = function(opts) end lsp.range_code_actions = function(opts) - opts.params = vim.lsp.util.make_given_range_params() + opts.params = vim.lsp.util.make_given_range_params({ opts.start_line, 1 }, { opts.end_line, 1 }) lsp.code_actions(opts) end diff --git a/lua/telescope/command.lua b/lua/telescope/command.lua index 8d47f5a..a92c29e 100644 --- a/lua/telescope/command.lua +++ b/lua/telescope/command.lua @@ -202,7 +202,7 @@ function command.register_keyword(keyword) split_keywords[keyword] = true end -function command.load_command(cmd, ...) +function command.load_command(start_line, end_line, count, cmd, ...) local args = { ... } if cmd == nil then run_command { cmd = "builtin" } @@ -211,7 +211,11 @@ function command.load_command(cmd, ...) local user_opts = {} user_opts["cmd"] = cmd - user_opts.opts = {} + user_opts.opts = { + start_line = start_line, + end_line = end_line, + count = count, + } for _, arg in ipairs(args) do if arg:find("=", 1) == nil then diff --git a/plugin/telescope.vim b/plugin/telescope.vim index 011b6e3..bb0228a 100644 --- a/plugin/telescope.vim +++ b/plugin/telescope.vim @@ -111,4 +111,4 @@ function! s:telescope_complete(arg,line,pos) endfunction " Telescope Commands with complete -command! -nargs=* -complete=custom,s:telescope_complete Telescope lua require('telescope.command').load_command() +command! -nargs=* -range -complete=custom,s:telescope_complete Telescope lua require('telescope.command').load_command(, , , )