Skip to content

Commit fc3787e

Browse files
committed
feat: add config.fuzzy_finder_mappings to customize mappings for popup input window in fuzzy_finder_mode
related issue: #451 (comment)
1 parent 20c2f2f commit fc3787e

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,21 @@ use {
292292
["<c-x>"] = "clear_filter",
293293
["[g"] = "prev_git_modified",
294294
["]g"] = "next_git_modified",
295-
}
295+
},
296+
297+
fuzzy_finder_mappings = nil, -- use a custom function for defining keymaps in popup input window
298+
-- fuzzy_finder_mappings = function(input, state, scroll_padding)
299+
-- -- you can use input:unmap('i', '<C-n>', true) to remove imap "<C-n>" defined by neo-tree
300+
-- input:map('i', '<C-j>', function()
301+
-- local renderer = require('neo-tree.ui.renderer')
302+
-- renderer.focus_node(state, nil, true, 1, scroll_padding)
303+
-- end, { noremap = true })
304+
-- input:map('i', '<C-k>', function()
305+
-- local renderer = require('neo-tree.ui.renderer')
306+
-- renderer.focus_node(state, nil, true, -1, scroll_padding)
307+
-- vim.cmd('redraw!')
308+
-- end, { noremap = true })
309+
-- end,
296310
}
297311
},
298312
buffers = {

lua/neo-tree/defaults.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ local config = {
369369
["."] = "set_root",
370370
["[g"] = "prev_git_modified",
371371
["]g"] = "next_git_modified",
372-
}
372+
},
373+
fuzzy_finder_mappings = nil , -- use a custom function for defining keymaps in popup input window
373374
},
374375
async_directory_scan = "auto", -- "auto" means refreshes are async, but it's synchronous when called from the Neotree commands.
375376
-- "always" means directory scans are always async.

lua/neo-tree/sources/filesystem/lib/filter.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ local vim = vim
44
local Input = require("nui.input")
55
local event = require("nui.utils.autocmd").event
66
local fs = require("neo-tree.sources.filesystem")
7-
local inputs = require("neo-tree.ui.inputs")
87
local popups = require("neo-tree.ui.popups")
98
local renderer = require("neo-tree.ui.renderer")
109
local utils = require("neo-tree.utils")
1110
local log = require("neo-tree.log")
1211
local manager = require("neo-tree.sources.manager")
13-
local renderer = require("neo-tree.ui.renderer")
1412

1513
local M = {}
1614

@@ -214,6 +212,11 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode, use_fzy)
214212
input:map("i", "<C-n>", move_cursor_down, { noremap = true })
215213
input:map("i", "<up>", move_cursor_up, { noremap = true })
216214
input:map("i", "<C-p>", move_cursor_up, { noremap = true })
215+
216+
local fuzzy_finder_mappings = require("neo-tree").config.filesystem.window.fuzzy_finder_mappings
217+
if fuzzy_finder_mappings then
218+
fuzzy_finder_mappings(input, state, scroll_padding)
219+
end
217220
end
218221
end
219222

0 commit comments

Comments
 (0)