diff --git a/README.md b/README.md index 608f8e3f..6693934c 100644 --- a/README.md +++ b/README.md @@ -348,12 +348,14 @@ use { ["on"] = { "order_by_name", nowait = false }, ["os"] = { "order_by_size", nowait = false }, ["ot"] = { "order_by_type", nowait = false }, + -- [''] = function(state) ... end, }, fuzzy_finder_mappings = { -- define keymaps for filter popup window in fuzzy_finder_mode [""] = "move_cursor_down", [""] = "move_cursor_down", [""] = "move_cursor_up", [""] = "move_cursor_up", + -- [''] = function(state, scroll_padding) ... end, }, }, diff --git a/lua/neo-tree/sources/common/filters/init.lua b/lua/neo-tree/sources/common/filters/init.lua index 6941a2fc..8575c7eb 100644 --- a/lua/neo-tree/sources/common/filters/init.lua +++ b/lua/neo-tree/sources/common/filters/init.lua @@ -213,9 +213,16 @@ M.show_filter = function(state, search_as_you_type, keep_filter_on_submit) local config = require("neo-tree").config for lhs, cmd_name in pairs(config.filesystem.window.fuzzy_finder_mappings) do - local cmd = cmds[cmd_name] - if cmd then - input:map("i", lhs, utils.wrap(cmd, state, scroll_padding), { noremap = true }) + local t = type(cmd_name) + if t == "string" then + local cmd = cmds[cmd_name] + if cmd then + input:map("i", lhs, utils.wrap(cmd, state, scroll_padding), { noremap = true }) + else + log.warn(string.format("Invalid command in fuzzy_finder_mappings: %s = %s", lhs, cmd_name)) + end + elseif t == "function" then + input:map("i", lhs, utils.wrap(cmd_name, state, scroll_padding), { noremap = true }) else log.warn(string.format("Invalid command in fuzzy_finder_mappings: %s = %s", lhs, cmd_name)) end diff --git a/lua/neo-tree/sources/filesystem/lib/filter.lua b/lua/neo-tree/sources/filesystem/lib/filter.lua index 8618ce35..90e7d456 100644 --- a/lua/neo-tree/sources/filesystem/lib/filter.lua +++ b/lua/neo-tree/sources/filesystem/lib/filter.lua @@ -220,11 +220,19 @@ M.show_filter = function(state, search_as_you_type, fuzzy_finder_mode, use_fzy) if fuzzy_finder_mode then local config = require("neo-tree").config for lhs, cmd_name in pairs(config.filesystem.window.fuzzy_finder_mappings) do - local cmd = cmds[cmd_name] - if cmd then - input:map("i", lhs, create_input_mapping_handle(cmd, state, scroll_padding), { noremap = true }) + local t = type(cmd_name) + if t == "string" then + local cmd = cmds[cmd_name] + if cmd then + input:map("i", lhs, create_input_mapping_handle(cmd, state, scroll_padding), { noremap = true }) + else + log.warn(string.format("Invalid command in fuzzy_finder_mappings: %s = %s", lhs, cmd_name)) + end + elseif t == "function" then + input:map("i", lhs, create_input_mapping_handle(cmd_name, state, scroll_padding), + { noremap = true }) else - log.warn(string.format('Invalid command in fuzzy_finder_mappings: %s = %s', lhs, cmd_name)) + log.warn(string.format("Invalid command in fuzzy_finder_mappings: %s = %s", lhs, cmd_name)) end end end