Skip to content

Commit

Permalink
feat: add next and prev item
Browse files Browse the repository at this point in the history
  • Loading branch information
otavioschwanck committed Mar 23, 2024
1 parent 7e74ae3 commit 10d1718
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Just press the leader_key set on setup and follow you heart. (Is that easy)
open_horizontal = "-",
quit = "q",
remove = "x", -- only used if separate_save_and_remove is true
next_item = "]",
prev_item = "["
},
custom_actions = {
open = function(target_file_name, current_file_name) end, -- target_file_name = file selected to be open, current_file_name = filename from where this was called
Expand Down
2 changes: 2 additions & 0 deletions lua/arrow/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function M.setup(opts)
open_horizontal = "-",
quit = "q",
remove = "x",
next_item = "]",
prev_item = "[",
}

local default_window_config = {
Expand Down
15 changes: 14 additions & 1 deletion lua/arrow/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ local function getActionsMenu()
string.format("%s Delete mode", mappings.delete_mode),
string.format("%s Open Vertical", mappings.open_vertical),
string.format("%s Open Horizontal", mappings.open_horizontal),
string.format("%s Next Item", mappings.next_item),
string.format("%s Prev Item", mappings.prev_item),
string.format("%s Quit", mappings.quit),
}

Expand Down Expand Up @@ -361,7 +363,7 @@ function M.getWindowConfig()
local height = #fileNames + 2

if show_handbook then
height = height + 8
height = height + 10
if separate_save_and_remove then
height = height + 1
end
Expand Down Expand Up @@ -462,6 +464,17 @@ function M.openMenu()
persist.clear()
closeMenu()
end, menuKeymapOpts)

vim.keymap.set("n", mappings.next_item, function()
closeMenu()
persist.next()
end, menuKeymapOpts)

vim.keymap.set("n", mappings.prev_item, function()
closeMenu()
persist.previous()
end, menuKeymapOpts)

vim.keymap.set("n", "<Esc>", closeMenu, menuKeymapOpts)

vim.keymap.set("n", mappings.delete_mode, function()
Expand Down

0 comments on commit 10d1718

Please sign in to comment.