Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use the Pomodoro Technique in Neovim with built-in session tracking and break re
delay_duration = 1, -- The additionnal work time you get when you delay a break
long_break_duration = 15,
breaks_before_long = 4,
display_ui_on_break = true, -- Disable it if you only want to see the lualine
},
},

Expand Down
10 changes: 9 additions & 1 deletion lua/pomodoro/pomodoro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Phases = constants.Phases
---@field start_at_launch boolean
---@field timer uv_timer_t
---@field phase integer
---@field display_ui_on_break boolean
local pomodoro = {}

-- Work duration in ms
Expand All @@ -33,6 +34,7 @@ pomodoro.start_at_launch = true
pomodoro.timer = uv.new_timer()
pomodoro.started_timer_time = uv.now()
pomodoro.phase = Phases.NOT_RUNNING
pomodoro.display_ui_on_break = true

---@param time number
---@param fn function
Expand Down Expand Up @@ -125,7 +127,9 @@ function pomodoro.startBreak(forced_time)
end

info("Break of " .. break_duration / MIN_IN_MS .. "m started!")
vim.schedule(pomodoro.displayPomodoroUI)
if pomodoro.display_ui_on_break then
vim.schedule(pomodoro.displayPomodoroUI)
end
pomodoro.startTimer(break_duration, pomodoro.endBreak)
end

Expand Down Expand Up @@ -205,6 +209,7 @@ end
---@field delay_duration? number
---@field breaks_before_long? number
---@field start_at_launch? boolean
---@field display_ui_on_break? boolean

---@param opts PomodoroOpts
function pomodoro.setup(opts)
Expand All @@ -227,6 +232,9 @@ function pomodoro.setup(opts)
if opts.start_at_launch ~= nil then
pomodoro.start_at_launch = opts.start_at_launch
end
if opts.display_ui_on_break ~= nil then
pomodoro.display_ui_on_break = opts.display_ui_on_break
end
end

pomodoro.registerCmds()
Expand Down
5 changes: 5 additions & 0 deletions lua/pomodoro/tests/pomodoro_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("useless tests", function()
opts.long_break_duration = 15
opts.breaks_before_long = 4
opts.start_at_launch = false
opts.display_ui_on_break = false
pomodoro.setup(opts)
assert(
pomodoro.work_duration == opts.work_duration * MIN_IN_MS,
Expand All @@ -37,6 +38,10 @@ describe("useless tests", function()
pomodoro.start_at_launch == opts.start_at_launch,
"Opt start_at_launch"
)
assert(
pomodoro.display_ui_on_break == opts.display_ui_on_break,
"Opt display_ui_on_break"
)
end)
--TODO: tests
end)