mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
Added nav_next and nav_prev functions
This allows to cycle through the harpoon marks list
This commit is contained in:
parent
dcaf802877
commit
0280f8be12
@ -203,5 +203,9 @@ end
|
||||
|
||||
M.to_quickfix_list()
|
||||
|
||||
M.get_current_index = function()
|
||||
return M.get_index_of(vim.fn.bufname(vim.fn.bufnr()))
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
@ -134,5 +134,38 @@ function M.close_notification(bufnr)
|
||||
vim.api.nvim_buf_delete(bufnr)
|
||||
end
|
||||
|
||||
M.nav_next = function()
|
||||
local current_index = Marked.get_current_index()
|
||||
local number_of_items = Marked.get_length()
|
||||
|
||||
if current_index == nil then
|
||||
current_index = 1
|
||||
else
|
||||
current_index = current_index + 1
|
||||
end
|
||||
|
||||
if (current_index > number_of_items) then
|
||||
current_index = 1
|
||||
end
|
||||
M.nav_file(current_index)
|
||||
end
|
||||
|
||||
M.nav_prev = function()
|
||||
local current_index = Marked.get_current_index()
|
||||
local number_of_items = Marked.get_length()
|
||||
|
||||
if current_index == nil then
|
||||
current_index = number_of_items
|
||||
else
|
||||
current_index = current_index - 1
|
||||
end
|
||||
|
||||
if (current_index < 1) then
|
||||
current_index = number_of_items
|
||||
end
|
||||
|
||||
M.nav_file(current_index)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user