Skip to content

Commit

Permalink
fix: show the correctly bound key for the top Status Hint
Browse files Browse the repository at this point in the history
Fixes NeogitOrg#564 (partially)
  • Loading branch information
PriceHiller committed Jul 15, 2023
1 parent cc77769 commit 1810292
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
local M = {}

function M.get_reversed_status_maps()
return vim.tbl_add_reverse_lookup(vim.tbl_deep_extend("force", M.values.mappings.status, {}))
end

M.values = {
disable_hint = false,
disable_context_highlighting = false,
Expand Down
4 changes: 1 addition & 3 deletions lua/neogit/popups/help/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ local util = require("neogit.lib.util")
local NONE = function() end

-- Using deep extend this way creates a copy of the mapping values
local status_mappings = vim.tbl_add_reverse_lookup(
vim.tbl_deep_extend("force", require("neogit.config").values.mappings.status, {})
)
local status_mappings = require("neogit.config").get_reversed_status_maps()

local function present(commands)
local presenter = util.map(commands, function(command)
Expand Down
17 changes: 16 additions & 1 deletion lua/neogit/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,22 @@ local function draw_buffer()

local output = LineBuffer.new()
if not config.values.disable_hint then
output:append("Hint: [<tab>] toggle diff | [s]tage | [u]nstage | [x] discard | [c]ommit | [?] more help")
local reversed_status_map = config.get_reversed_status_maps()

local function hint_label(map_name, hint)
return "[" .. reversed_status_map[map_name] .. "] " .. hint
end

local hints = {
hint_label("Toggle", "toggle diff"),
hint_label("Stage", "stage"),
hint_label("Unstage", "unstage"),
hint_label("Discard", "discard"),
hint_label("CommitPopup", "commit"),
hint_label("HelpPopup", "HelpPopup"),
}

output:append("Hint: " .. table.concat(hints, " | "))
output:append("")
end

Expand Down

0 comments on commit 1810292

Please sign in to comment.