added custom options to 'register_ui_select'

main
bhagwan 2 years ago
parent 475ffb2673
commit f466e20196

@ -3,6 +3,7 @@ local utils = require "fzf-lua.utils"
local M = {}
local _opts = nil
local _old_ui_select = nil
M.deregister = function()
@ -11,14 +12,16 @@ M.deregister = function()
end
vim.ui.select = _old_ui_select
_old_ui_select = nil
_opts = nil
end
M.register = function()
M.register = function(opts)
if vim.ui.select == M.ui_select then
-- already registered
utils.info("vim.ui.select already registered to fzf-lua")
return
end
_opts = opts
_old_ui_select = vim.ui.select
vim.ui.select = M.ui_select
end
@ -53,14 +56,14 @@ M.ui_select = function(items, opts, on_choice)
opts.format_item(e)))
end
local o = {}
o.fzf_opts = {
_opts = _opts or {}
_opts.fzf_opts = {
['--no-multi'] = '',
['--prompt'] = opts.prompt:gsub(":$", "> "),
['--preview-window'] = 'hidden:right:0',
}
core.fzf_wrap(o, entries, function(selected)
core.fzf_wrap(_opts, entries, function(selected)
local idx = selected and tonumber(selected[1]:match("^(%d+).")) or nil
on_choice(items[idx], idx)

Loading…
Cancel
Save