Skip to content

Commit

Permalink
add command keymaps to buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGruber committed Sep 8, 2024
1 parent 1c96e39 commit 2c7f8d1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lua/pomodoro/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ local function set_exit_key(buffer, mode, key)
{ noremap = true, silent = true }
)
end
-- Set an exit key for a buffer
---@param buffer integer --
---@param mode string --
---@param key string --
local function set_command_key(buffer, mode, key, command)
vim.api.nvim_buf_set_keymap(
buffer,
mode,
key,
string.format(":%s<CR>", command),
{ noremap = true, silent = true }
)
end
-- Apply custom keymaps to a buffer
---@param buffer integer --
local function apply_buffer_keymaps(buffer)
Expand All @@ -41,6 +54,10 @@ local function apply_buffer_keymaps(buffer)
disable_key(buffer, "n", "r")
disable_key(buffer, "n", "u")
disable_key(buffer, "n", "<C-r>")
set_command_key(buffer, "n", "<C-q>", "PomodoroStop")
set_command_key(buffer, "n", "<C-s>", "PomodoroSkipBreak")
-- TODO:
set_command_key(buffer, "n", "<C-y>", "PomodoroAddTime")
end
---@return integer
local function createBufferUi()
Expand Down

0 comments on commit 2c7f8d1

Please sign in to comment.