Skip to content

Commit

Permalink
chore: prefer footer override keymaps over defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh committed Feb 20, 2024
1 parent 02e8f0d commit 6d7972b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions lua/kitty-scrollback/footer_win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ M.open_footer_window = function(winopts, refresh_only)
)
)

local default_footer_keys = {
['<Plug>(KsbNormalYank)'] = vim.fn.keytrans((vim.g.mapleader or '\\') .. 'y'):gsub('<lt>', '<'),
['<Plug>(KsbExecuteCmd)'] = '<C-CR>',
['<Plug>(KsbPasteCmd)'] = '<S-CR>',
['<Plug>(KsbToggleFooter)'] = 'g?',
}

local footer_keys = {
[plug.NORMAL_YANK] = false,
[plug.EXECUTE_CMD] = false,
Expand All @@ -105,21 +112,24 @@ M.open_footer_window = function(winopts, refresh_only)
local rhs = km.rhs
if footer_keys[rhs] ~= nil then
local lhs = vim.fn.keytrans(km.lhs):gsub('<lt>', '<')
footer_keys[rhs] = lhs
if not footer_keys[rhs] or (footer_keys[rhs] and lhs ~= default_footer_keys[rhs]) then
footer_keys[rhs] = lhs
end
end
end

local write_msg = '`:w` *Paste* '
local footer_msg = {}
if footer_keys[plug.NORMAL_YANK] then
table.insert(footer_msg, ('`%s` *Yank*'):format(footer_keys[plug.NORMAL_YANK]))
table.insert(footer_msg, ('`%s` *Yank* '):format(footer_keys[plug.NORMAL_YANK]))
end
if footer_keys[plug.EXECUTE_CMD] then
table.insert(footer_msg, (' `%s` *Execute*'):format(footer_keys[plug.EXECUTE_CMD]))
table.insert(footer_msg, ('`%s` *Execute* '):format(footer_keys[plug.EXECUTE_CMD]))
end
if footer_keys[plug.PASTE_CMD] then
table.insert(footer_msg, (' `%s` *Paste*'):format(footer_keys[plug.PASTE_CMD]))
table.insert(footer_msg, ('`%s` *Paste* '):format(footer_keys[plug.PASTE_CMD]))
end
table.insert(footer_msg, ' `:w` *Paste* ')
table.insert(footer_msg, write_msg)
if footer_keys[plug.TOGGLE_FOOTER] then
table.insert(footer_msg, ('`%s` *Toggle* *Mappings*'):format(footer_keys[plug.TOGGLE_FOOTER]))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ N▏# example > --config ksb_example_keymaps_disabled
T▏ ▕
$🭼▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭿
$▏ ▕
$▏ :w Paste
$▏ :w Paste
$🭼▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭿
]],
168
Expand Down

0 comments on commit 6d7972b

Please sign in to comment.