Skip to content

Commit 5e3c112

Browse files
committed
feat(ui): use [[ & ]] to navigate between plugins. Fixes #1463
1 parent 3772914 commit 5e3c112

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lua/lazy/view/config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ M.keys = {
3434
profile_sort = "<C-s>",
3535
profile_filter = "<C-f>",
3636
abort = "<C-c>",
37+
next = "]]",
38+
prev = "[[",
3739
}
3840

3941
---@type table<string,LazyViewCommand>

lua/lazy/view/init.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ function M.create()
111111
end
112112
end)
113113

114+
self:on_key(ViewConfig.keys.next, function()
115+
local cursor = vim.api.nvim_win_get_cursor(self.view.win)
116+
for l = 1, #self.render.locations, 1 do
117+
local loc = self.render.locations[l]
118+
if loc.from > cursor[1] then
119+
vim.api.nvim_win_set_cursor(self.view.win, { loc.from, 8 })
120+
return
121+
end
122+
end
123+
end)
124+
125+
self:on_key(ViewConfig.keys.prev, function()
126+
local cursor = vim.api.nvim_win_get_cursor(self.view.win)
127+
for l = #self.render.locations, 1, -1 do
128+
local loc = self.render.locations[l]
129+
if loc.from < cursor[1] then
130+
vim.api.nvim_win_set_cursor(self.view.win, { loc.from, 8 })
131+
return
132+
end
133+
end
134+
end)
135+
114136
self:on_key(ViewConfig.keys.profile_sort, function()
115137
if self.state.mode == "profile" then
116138
self.state.profile.sort_time_taken = not self.state.profile.sort_time_taken

lua/lazy/view/render.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,15 @@ function M:help()
201201
:nl()
202202
self:append("or the plugin was just updated. Otherwise the plugin webpage will open."):nl():nl()
203203

204-
self:append("Use "):append("<d>", "LazySpecial"):append(" on a commit or plugin to open the diff view"):nl()
204+
self:append("Use "):append("<d>", "LazySpecial"):append(" on a commit or plugin to open the diff view"):nl():nl()
205+
self
206+
:append("Use ")
207+
:append("<]]>", "LazySpecial")
208+
:append(" and ")
209+
:append("<[[>", "LazySpecial")
210+
:append(" to navigate between plugins")
211+
:nl()
212+
:nl()
205213
self:nl()
206214

207215
self:append("Keyboard Shortcuts", "LazyH2"):nl()

0 commit comments

Comments
 (0)