Compare commits

...

1 Commits

Author SHA1 Message Date
Dmitriy Kovalenko a5804d3b06 feat(picker): add telescope-style user mappings
Closes #78. Expose `mappings = { i = {...}, n = {...} }` config to bind
arbitrary lhs to function/string rhs on the input buffer, applied after
built-in keymaps.
2026-05-21 06:25:00 -07:00
3 changed files with 26 additions and 0 deletions
+8
View File
@@ -244,6 +244,14 @@ require('fff').setup({
focus_list = '<leader>l',
focus_preview = '<leader>p',
},
-- Telescope-style user mappings on the input buffer, keyed by mode (`i` / `n`).
-- Values may be a function or a string (rhs). Applied on top of built-in keymaps.
mappings = {
i = {
-- ["<A-BS>"] = function() vim.api.nvim_input("<C-w>") end,
},
n = {},
},
frecency = {
enabled = true,
db_path = vim.fn.stdpath('cache') .. '/fff_nvim',
+11
View File
@@ -69,6 +69,7 @@ local M = {}
--- @field layout FffLayoutConfig
--- @field preview FffPreviewConfig
--- @field keymaps FffKeymapsConfig
--- @field mappings table<string, table<string, function|string>> User-defined per-mode keymaps. Telescope-style: { i = { ["<A-BS>"] = fn }, n = { ... } }. Mapped on the input buffer.
--- @field hl table<string, string>
--- @field frecency FffFrecencyConfig
--- @field history FffHistoryConfig
@@ -262,6 +263,16 @@ local function init()
focus_list = '<leader>l',
focus_preview = '<leader>p',
},
-- Telescope-style user mappings keyed by mode. Mapped on the input buffer.
-- Example:
-- mappings = {
-- i = { ["<A-BS>"] = function() vim.api.nvim_input("<C-w>") end },
-- n = { ["<C-r>"] = function() ... end },
-- }
mappings = {
i = {},
n = {},
},
hl = {
border = 'FloatBorder',
normal = 'Normal',
+7
View File
@@ -1195,6 +1195,13 @@ function M.setup_keymaps()
set_keymap({ 'i', 'n' }, keymaps.send_to_quickfix, M.send_to_quickfix, input_opts)
set_keymap({ 'i', 'n' }, keymaps.cycle_grep_modes, M.cycle_grep_modes, input_opts)
local user_mappings = M.state.config.mappings or {}
for _, mode in ipairs({ 'i', 'n' }) do
for lhs, rhs in pairs(user_mappings[mode] or {}) do
if type(rhs) == 'function' or type(rhs) == 'string' then vim.keymap.set(mode, lhs, rhs, input_opts) end
end
end
-- List buffer
set_keymap('n', keymaps.close, M.close, list_opts)
set_keymap('n', 'q', M.close, list_opts)