improved actions for command_history|search_history (closes issue #75)

main
bhagwan 3 years ago
parent 9fb6a3059f
commit 6aff90f99b

@ -139,7 +139,12 @@ M.ex_run = function(selected)
local cmd = selected[1]
if #selected>1 then cmd = selected[2] end
vim.cmd("stopinsert")
vim.fn.feedkeys(string.format(":%s ", cmd))
vim.fn.feedkeys(string.format(":%s", cmd))
end
M.ex_run_cr = function(selected)
M.ex_run(selected)
utils.feed_keys_termcodes("<CR>")
end
M.search = function(selected)
@ -147,7 +152,12 @@ M.search = function(selected)
local query = selected[1]
if #selected>1 then query = selected[2] end
vim.cmd("stopinsert")
utils.feed_keys_termcodes(string.format("/%s<CR>", query))
vim.fn.feedkeys(string.format("/%s", query))
end
M.search_cr = function(selected)
M.search(selected)
utils.feed_keys_termcodes("<CR>")
end
M.goto_mark = function(selected)

@ -405,13 +405,15 @@ M.globals.nvim = {
command_history = {
prompt = 'Command History> ',
actions = {
["default"] = actions.ex_run,
["default"] = actions.ex_run_cr,
["ctrl-e"] = actions.ex_run,
},
},
search_history = {
prompt = 'Search History> ',
actions = {
["default"] = actions.search,
["default"] = actions.search_cr,
["ctrl-e"] = actions.search,
},
},
registers = {

@ -70,13 +70,21 @@ local history = function(opts, str)
end)()
end
local arg_header = function(sel_key, edit_key, text)
sel_key = utils.ansi_codes.yellow(sel_key)
edit_key = utils.ansi_codes.yellow(edit_key)
return ('--header=":: %s to %s, %s to edit"'):format(sel_key, text, edit_key)
end
M.command_history = function(opts)
opts = config.normalize_opts(opts, config.globals.nvim.command_history)
opts._fzf_cli_args = arg_header("<CR>", "<Ctrl-e>", "execute")
history(opts, "cmd")
end
M.search_history = function(opts)
opts = config.normalize_opts(opts, config.globals.nvim.search_history)
opts._fzf_cli_args = arg_header("<CR>", "<Ctrl-e>", "search")
history(opts, "search")
end

Loading…
Cancel
Save