Added harpoon_wrap option to default config as true. Reference this option in list:prev and list:next. When true allows prev and next to wrap the harpoon list, when false it will not wrap the harpoon list.

This commit is contained in:
mwishoff 2023-12-06 08:40:47 -08:00
parent 05edc3ee82
commit c82d3d5e3d
2 changed files with 9 additions and 2 deletions

View File

@ -74,6 +74,7 @@ function M.get_default_config()
},
default = {
harpoon_wrap = true,
--- select_with_nill allows for a list to call select even if the provided item is nil
select_with_nil = false,

View File

@ -171,8 +171,11 @@ end
function HarpoonList:next()
self._index = self._index + 1
if self._index > #self.items then
print(self._index)
if self._index > #self.items and self.config.harpoon_wrap then
self._index = 1
elseif self._index > #self.items and not self.config.harpoon_wrap then
self._index = #self.items
end
self:select(self._index)
@ -180,8 +183,11 @@ end
function HarpoonList:prev()
self._index = self._index - 1
if self._index < 1 then
print(self._index)
if self._index < 1 and self.config.harpoon_wrap then
self._index = #self.items
elseif self._index < 1 and not self.config.harpoon_wrap then
self._index = 1
end
self:select(self._index)