From da68f7bc2a678f49dfa24eaa169cda90aee031dd Mon Sep 17 00:00:00 2001 From: Quentin Gruber <47059878+QuentinGruber@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:22:46 +0200 Subject: [PATCH 1/2] Reword the command and function 'snooze' to 'delay' since it's more appropriate Rename the "snooze" command and function to "delayBreak" for better clarity. - **lua/pomodoro/pomodoro.lua**: - Rename the function `pomodoro.snooze` to `pomodoro.delayBreak`. - Rename the command `PomodoroSnooze` to `PomodoroDelayBreak`. - Rename the `snooze_duration` field in the `Pomodoro` class to `delay_duration`. - Rename the `snooze_duration` field in the `PomodoroOpts` class to `delay_duration`. - **lua/pomodoro/ui.lua**: - Rename the `PomodoroSnooze` command key to `PomodoroDelayBreak`. - **lua/pomodoro/tests/pomodoro_spec.lua**: - Rename the `snooze_duration` field in the test setup to `delay_duration`. - **README.md**: - Rename the `PomodoroSnooze` command in the usage section to `PomodoroDelayBreak`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/QuentinGruber/pomodoro.nvim?shareId=XXXX-XXXX-XXXX-XXXX). --- README.md | 2 +- lua/pomodoro/pomodoro.lua | 14 +++++++------- lua/pomodoro/tests/pomodoro_spec.lua | 6 +++--- lua/pomodoro/ui.lua | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9d4e7cc..9c21f7d 100644 --- a/README.md +++ b/README.md @@ -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. | diff --git a/lua/pomodoro/pomodoro.lua b/lua/pomodoro/pomodoro.lua index 8588383..07bf7fc 100644 --- a/lua/pomodoro/pomodoro.lua +++ b/lua/pomodoro/pomodoro.lua @@ -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() @@ -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() @@ -99,7 +99,7 @@ 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, @@ -110,7 +110,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 @@ -122,8 +122,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 diff --git a/lua/pomodoro/tests/pomodoro_spec.lua b/lua/pomodoro/tests/pomodoro_spec.lua index 65940e1..723bbc0 100644 --- a/lua/pomodoro/tests/pomodoro_spec.lua +++ b/lua/pomodoro/tests/pomodoro_spec.lua @@ -8,14 +8,14 @@ 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" + pomodoro.delay_duration == 10 * MIN_IN_MS, + "Opt delay_duration" ) assert(pomodoro.start_at_launch == false, "Opt start_at_launch") end) diff --git a/lua/pomodoro/ui.lua b/lua/pomodoro/ui.lua index 3dd0b94..970c738 100644 --- a/lua/pomodoro/ui.lua +++ b/lua/pomodoro/ui.lua @@ -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() @@ -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 @@ -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) From 9e9430cd44b4a9798623b570fce9af55b2481710 Mon Sep 17 00:00:00 2001 From: quentingruber Date: Tue, 10 Sep 2024 23:26:48 +0200 Subject: [PATCH 2/2] fix lint --- lua/pomodoro/pomodoro.lua | 6 +++++- lua/pomodoro/tests/pomodoro_spec.lua | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/pomodoro/pomodoro.lua b/lua/pomodoro/pomodoro.lua index 07bf7fc..da3b452 100644 --- a/lua/pomodoro/pomodoro.lua +++ b/lua/pomodoro/pomodoro.lua @@ -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("PomodoroDelayBreak", pomodoro.delayBreak, {}) + vim.api.nvim_create_user_command( + "PomodoroDelayBreak", + pomodoro.delayBreak, + {} + ) vim.api.nvim_create_user_command( "PomodoroUI", pomodoro.displayPomodoroUI, diff --git a/lua/pomodoro/tests/pomodoro_spec.lua b/lua/pomodoro/tests/pomodoro_spec.lua index 723bbc0..eb76e21 100644 --- a/lua/pomodoro/tests/pomodoro_spec.lua +++ b/lua/pomodoro/tests/pomodoro_spec.lua @@ -13,10 +13,7 @@ describe("useless tests", function() 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.delay_duration == 10 * MIN_IN_MS, - "Opt delay_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