Skip to content

Commit e45aaf8

Browse files
fjchen7sindrets
andauthored
feat: Allow hiding mappings from the help panel (#278)
Co-authored-by: Sindre T. Strøm <sindrets@gmail.com>
1 parent e3e15d8 commit e45aaf8

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ set of paths, and view the changes made in a diff split. This is a porcelain
6868
interface for git-log, and supports a good number of its options. Things like:
6969

7070
- Filtering commits by grepping commit messages and commit authors.
71-
- Tracing the line evolution of a given set of line ranges for multiple files.
71+
- Tracing the line evolution of a given set of line ranges for multiple files.
7272
- Only listing changes for a specific commit range, branch, or tag.
7373
- Following file changes through renames.
7474

@@ -175,7 +175,7 @@ require("diffview").setup({
175175
},
176176
view = {
177177
-- Configure the layout and behavior of different types of views.
178-
-- Available layouts:
178+
-- Available layouts:
179179
-- 'diff1_plain'
180180
-- |'diff2_horizontal'
181181
-- |'diff2_vertical'

doc/diffview.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,15 @@ keymaps *diffview-config-keymaps*
651651
}
652652
<
653653

654+
Setting a mapping's `desc` field to `"diffview_ignore"` will hide the
655+
mapping from the help panel: >
656+
657+
view = {
658+
-- Ignore mapping in the help panel
659+
{ "n", "<2-LeftMouse>", actions.select_entry, { desc = "diffview_ignore" } },
660+
}
661+
<
662+
654663
To disable all the default mappings simply set: >
655664
656665
keymaps = {

lua/diffview/ui/panels/help_panel.lua

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ function HelpPanel:update_components()
149149
return a < b
150150
end)
151151

152-
height = height + #maps + 3
153152
local items = { name = "items" }
154153
local section_schema = {
155154
name = "section",
@@ -163,17 +162,22 @@ function HelpPanel:update_components()
163162
}
164163

165164
for _, mapping in ipairs(maps) do
166-
width = math.max(width, 14 + 4 + #mapping[5] + 2)
167-
table.insert(items, {
168-
name = "item",
169-
context = {
170-
label_lhs = ("%14s"):format(mapping[2]),
171-
label_rhs = ("%s"):format(mapping[5]),
172-
mapping = mapping,
173-
},
174-
})
165+
local desc = mapping[5]
166+
167+
if desc ~= "diffview_ignore" then
168+
width = math.max(width, 14 + 4 + #mapping[5] + 2)
169+
table.insert(items, {
170+
name = "item",
171+
context = {
172+
label_lhs = ("%14s"):format(mapping[2]),
173+
label_rhs = desc,
174+
mapping = mapping,
175+
},
176+
})
177+
end
175178
end
176179

180+
height = height + #items + 3
177181
table.insert(sections, section_schema)
178182
end
179183

0 commit comments

Comments
 (0)