Skip to content

Commit da309da

Browse files
committed
Added: Mappings to navigate between sections in the status buffer
1 parent a919e63 commit da309da

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ neogit.setup {
402402
["]c"] = "OpenOrScrollDown",
403403
["<c-k>"] = "PeekUp",
404404
["<c-j>"] = "PeekDown",
405+
["<c-n>"] = "NextSection",
406+
["<c-p>"] = "PreviousSection",
405407
},
406408
},
407409
}

lua/neogit/buffers/status/actions.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,4 +1479,29 @@ M.n_command = function(self)
14791479
})
14801480
end)
14811481
end
1482+
1483+
---@param self StatusBuffer
1484+
M.n_next_section = function(self)
1485+
return function()
1486+
local section = self.buffer.ui:get_current_section()
1487+
if section then
1488+
local position = section.position.row_end + 2
1489+
self.buffer:move_cursor(position)
1490+
end
1491+
end
1492+
end
1493+
1494+
---@param self StatusBuffer
1495+
M.n_prev_section = function(self)
1496+
return function()
1497+
local section = self.buffer.ui:get_current_section()
1498+
if section then
1499+
local prev_section = self.buffer.ui:get_current_section(section.position.row_start - 1)
1500+
if prev_section then
1501+
self.buffer:move_cursor(prev_section.position.row_start + 1)
1502+
end
1503+
end
1504+
end
1505+
end
1506+
14821507
return M

lua/neogit/buffers/status/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ function M:open(kind)
171171
[mappings["TabOpen"]] = self:_action("n_tab_open"),
172172
[mappings["SplitOpen"]] = self:_action("n_split_open"),
173173
[mappings["VSplitOpen"]] = self:_action("n_vertical_split_open"),
174+
[mappings["NextSection"]] = self:_action("n_next_section"),
175+
[mappings["PreviousSection"]] = self:_action("n_prev_section"),
174176
[popups.mapping_for("BisectPopup")] = self:_action("n_bisect_popup"),
175177
[popups.mapping_for("BranchPopup")] = self:_action("n_branch_popup"),
176178
[popups.mapping_for("CherryPickPopup")] = self:_action("n_cherry_pick_popup"),

lua/neogit/config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ function M.get_default_values()
633633
["]c"] = "OpenOrScrollDown",
634634
["<c-k>"] = "PeekUp",
635635
["<c-j>"] = "PeekDown",
636+
["<c-n>"] = "NextSection",
637+
["<c-p>"] = "PreviousSection",
636638
},
637639
},
638640
}

0 commit comments

Comments
 (0)