Skip to content

Commit e03e0f9

Browse files
committed
add an option to disable break UI to appear on breaktime
1 parent 4565b21 commit e03e0f9

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Use the Pomodoro Technique in Neovim with built-in session tracking and break re
1717
delay_duration = 1, -- The additionnal work time you get when you delay a break
1818
long_break_duration = 15,
1919
breaks_before_long = 4,
20+
display_ui_on_break = true, -- Disable it if you only want to see the lualine
2021
},
2122
},
2223

lua/pomodoro/pomodoro.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local Phases = constants.Phases
1616
---@field start_at_launch boolean
1717
---@field timer uv_timer_t
1818
---@field phase integer
19+
---@field display_ui_on_break boolean
1920
local pomodoro = {}
2021

2122
-- Work duration in ms
@@ -33,6 +34,7 @@ pomodoro.start_at_launch = true
3334
pomodoro.timer = uv.new_timer()
3435
pomodoro.started_timer_time = uv.now()
3536
pomodoro.phase = Phases.NOT_RUNNING
37+
pomodoro.display_ui_on_break = true
3638

3739
---@param time number
3840
---@param fn function
@@ -125,7 +127,9 @@ function pomodoro.startBreak(forced_time)
125127
end
126128

127129
info("Break of " .. break_duration / MIN_IN_MS .. "m started!")
128-
vim.schedule(pomodoro.displayPomodoroUI)
130+
if pomodoro.display_ui_on_break then
131+
vim.schedule(pomodoro.displayPomodoroUI)
132+
end
129133
pomodoro.startTimer(break_duration, pomodoro.endBreak)
130134
end
131135

@@ -205,6 +209,7 @@ end
205209
---@field delay_duration? number
206210
---@field breaks_before_long? number
207211
---@field start_at_launch? boolean
212+
---@field display_ui_on_break? boolean
208213

209214
---@param opts PomodoroOpts
210215
function pomodoro.setup(opts)
@@ -227,6 +232,9 @@ function pomodoro.setup(opts)
227232
if opts.start_at_launch ~= nil then
228233
pomodoro.start_at_launch = opts.start_at_launch
229234
end
235+
if opts.display_ui_on_break ~= nil then
236+
pomodoro.display_ui_on_break = opts.display_ui_on_break
237+
end
230238
end
231239

232240
pomodoro.registerCmds()

lua/pomodoro/tests/pomodoro_spec.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe("useless tests", function()
1212
opts.long_break_duration = 15
1313
opts.breaks_before_long = 4
1414
opts.start_at_launch = false
15+
opts.display_ui_on_break = false
1516
pomodoro.setup(opts)
1617
assert(
1718
pomodoro.work_duration == opts.work_duration * MIN_IN_MS,
@@ -37,6 +38,10 @@ describe("useless tests", function()
3738
pomodoro.start_at_launch == opts.start_at_launch,
3839
"Opt start_at_launch"
3940
)
41+
assert(
42+
pomodoro.display_ui_on_break == opts.display_ui_on_break,
43+
"Opt display_ui_on_break"
44+
)
4045
end)
4146
--TODO: tests
4247
end)

0 commit comments

Comments
 (0)