Skip to content

Commit

Permalink
Merge pull request #1 from QuentinGruber/rename-snooze-to-delay
Browse files Browse the repository at this point in the history
Reword the command and function 'snooze' to 'delay' since it's more appropriate
  • Loading branch information
QuentinGruber authored Sep 10, 2024
2 parents 1ebf3dd + 9e9430c commit 9b4c500
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Display time spent on projects / files
| `:PomodoroUI` | Display the Pomodoro UI. |
| `:PomodoroSkipBreak` | Skip the current break and start the next work session. |
| `:PomodoroForceBreak` | Forcefully start a break. |
| `:PomodoroSnooze` | Delay the current break by a snooze duration. |
| `:PomodoroDelayBreak` | Delay the current break by a delay duration. |
18 changes: 11 additions & 7 deletions lua/pomodoro/pomodoro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ local pomodoro = {}
pomodoro.work_duration = 25 * MIN_IN_MS
-- Break duration in ms
pomodoro.break_duration = 5 * MIN_IN_MS
-- Snooze duration in ms
pomodoro.snooze_duration = 1 * MIN_IN_MS
-- Delay duration in ms
pomodoro.delay_duration = 1 * MIN_IN_MS
pomodoro.timer_duration = 0
pomodoro.start_at_launch = true
pomodoro.timer = vim.uv.new_timer()
Expand Down Expand Up @@ -76,7 +76,7 @@ function pomodoro.start()
pomodoro.startTimer(pomodoro.work_duration, pomodoro.startBreak)
end

function pomodoro.snooze()
function pomodoro.delayBreak()
if pomodoro.phase == Phases.BREAK then
pomodoro.phase = Phases.RUNNING
pomodoro.closePomodoroUi()
Expand All @@ -99,7 +99,11 @@ function pomodoro.registerCmds()
vim.api.nvim_create_user_command("PomodoroSkipBreak", pomodoro.endBreak, {})
vim.api.nvim_create_user_command("PomodoroStart", pomodoro.start, {})
vim.api.nvim_create_user_command("PomodoroStop", pomodoro.stop, {})
vim.api.nvim_create_user_command("PomodoroSnooze", pomodoro.snooze, {})
vim.api.nvim_create_user_command(
"PomodoroDelayBreak",
pomodoro.delayBreak,
{}
)
vim.api.nvim_create_user_command(
"PomodoroUI",
pomodoro.displayPomodoroUI,
Expand All @@ -110,7 +114,7 @@ end
---@class PomodoroOpts
---@field work_duration? number
---@field break_duration? number
---@field snooze_duration? number
---@field delay_duration? number
---@field start_at_launch? boolean

---@param opts PomodoroOpts
Expand All @@ -122,8 +126,8 @@ function pomodoro.setup(opts)
if opts.break_duration ~= nil then
pomodoro.break_duration = opts.break_duration * MIN_IN_MS
end
if opts.snooze_duration ~= nil then
pomodoro.snooze_duration = opts.snooze_duration * MIN_IN_MS
if opts.delay_duration ~= nil then
pomodoro.delay_duration = opts.delay_duration * MIN_IN_MS
end
if opts.start_at_launch ~= nil then
pomodoro.start_at_launch = opts.start_at_launch
Expand Down
7 changes: 2 additions & 5 deletions lua/pomodoro/tests/pomodoro_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ describe("useless tests", function()
local MIN_IN_MS = 60000
opts.work_duration = 10
opts.break_duration = 10
opts.snooze_duration = 10
opts.delay_duration = 10
opts.start_at_launch = false
pomodoro.setup(opts)
assert(pomodoro.work_duration == 10 * MIN_IN_MS, "Opt work_duration")
assert(pomodoro.break_duration == 10 * MIN_IN_MS, "Opt break_duration")
assert(
pomodoro.snooze_duration == 10 * MIN_IN_MS,
"Opt snooze_duration"
)
assert(pomodoro.delay_duration == 10 * MIN_IN_MS, "Opt delay_duration")
assert(pomodoro.start_at_launch == false, "Opt start_at_launch")
end)
--TODO: tests
Expand Down
6 changes: 3 additions & 3 deletions lua/pomodoro/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local function apply_buffer_keymaps(buffer)
set_command_key(buffer, "n", "Q", "PomodoroStop")
set_command_key(buffer, "n", "W", "PomodoroSkipBreak")
set_command_key(buffer, "n", "B", "PomodoroForceBreak")
set_command_key(buffer, "n", "S", "PomodoroSnooze")
set_command_key(buffer, "n", "D", "PomodoroDelayBreak")
end
---@return integer
local function createBufferUi()
Expand Down Expand Up @@ -110,7 +110,7 @@ function UI.get_buffer_data(pomodoro)
table.insert(data, spaces(1) .. "Time to take a break !")
table.insert(data, spaces(5) .. time_left_string)
table.insert(data, "[W] Work [Q] Stop")
table.insert(data, "[S] Snooze")
table.insert(data, "[D] DelayBreak")
end
return data
end
Expand All @@ -130,7 +130,7 @@ function UI.updateUi(pomodoro)
UI.startRenderingTimer(pomodoro)
else
if pomodoro.phase == Phases.BREAK then
pomodoro.snooze()
pomodoro.delayBreak()
end
end
end)
Expand Down

0 comments on commit 9b4c500

Please sign in to comment.