Merge pull request #41 from Bhanukamax/feature/cycle

Added nav_next and nav_prev functions
This commit is contained in:
ThePrimeagen 2021-03-22 10:12:46 -06:00 committed by GitHub
commit 97e0bf5c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -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

View File

@ -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