Skip to content

Commit 4565b21

Browse files
Merge pull request #13 from QuentinGruber/dev
Release 1.1.0
2 parents 0c11df8 + 64e4a53 commit 4565b21

File tree

3 files changed

+47
-28
lines changed

3 files changed

+47
-28
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
include:
1515
- os: ubuntu-22.04
16-
rev: nightly/nvim-linux64.tar.gz
16+
rev: nightly/nvim-linux-x86_64.tar.gz
1717
- os: ubuntu-22.04
1818
rev: v0.9.0/nvim-linux64.tar.gz
1919
steps:
@@ -44,12 +44,12 @@ jobs:
4444
name: Stylua
4545
runs-on: ubuntu-latest
4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v4
4848
- run: date +%W > weekly
4949

5050
- name: Restore cache
5151
id: cache
52-
uses: actions/cache@v2
52+
uses: actions/cache@v4
5353
with:
5454
path: |
5555
~/.cargo/bin
@@ -65,7 +65,7 @@ jobs:
6565
name: Luacheck
6666
runs-on: ubuntu-latest
6767
steps:
68-
- uses: actions/checkout@v2
68+
- uses: actions/checkout@v4
6969
- name: Setup
7070
run: |
7171
sudo apt-get update

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ Use the Pomodoro Technique in Neovim with built-in session tracking and break re
4242

4343
## Usage
4444

45-
| Command | Description |
46-
| --------------------- | ------------------------------------------------------- |
47-
| `:PomodoroStart` | Start the Pomodoro timer. |
48-
| `:PomodoroStop` | Stop the Pomodoro timer. |
49-
| `:PomodoroUI` | Display the Pomodoro UI. |
50-
| `:PomodoroSkipBreak` | Skip the current break and start the next work session. |
51-
| `:PomodoroForceBreak` | Forcefully start a break. |
52-
| `:PomodoroDelayBreak` | Delay the current break by a delay duration. |
45+
| Command | Description |
46+
| --------------------------------- | ------------------------------------------------------- |
47+
| `:PomodoroStart {duration?}` | Start the Pomodoro timer. |
48+
| `:PomodoroStop` | Stop the Pomodoro timer. |
49+
| `:PomodoroUI` | Display the Pomodoro UI. |
50+
| `:PomodoroSkipBreak` | Skip the current break and start the next work session. |
51+
| `:PomodoroForceBreak {duration?}` | Forcefully start a break. |
52+
| `:PomodoroDelayBreak` | Delay the current break by a delay duration. |

lua/pomodoro/pomodoro.lua

+35-16
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@ function pomodoro.isInLongBreak()
110110
and pomodoro.phase == Phases.BREAK
111111
end
112112

113-
function pomodoro.startBreak()
114-
pomodoro.phase = Phases.BREAK
115-
pomodoro.break_count = pomodoro.break_count + 1
113+
---@param forced_time? number
114+
function pomodoro.startBreak(forced_time)
116115
local break_duration
117-
if pomodoro.isInLongBreak() then
118-
break_duration = pomodoro.long_break_duration
116+
if forced_time then
117+
break_duration = forced_time * MIN_IN_MS
119118
else
120119
break_duration = pomodoro.break_duration
121120
end
121+
pomodoro.phase = Phases.BREAK
122+
pomodoro.break_count = pomodoro.break_count + 1
123+
if pomodoro.isInLongBreak() and not forced_time then
124+
break_duration = pomodoro.long_break_duration
125+
end
122126

123127
info("Break of " .. break_duration / MIN_IN_MS .. "m started!")
124128
vim.schedule(pomodoro.displayPomodoroUI)
@@ -131,12 +135,17 @@ function pomodoro.endBreak()
131135
pomodoro.start()
132136
end
133137

134-
function pomodoro.start()
135-
info(
136-
"Work session of " .. pomodoro.work_duration / MIN_IN_MS .. "m started!"
137-
)
138+
---@param forced_time? number
139+
function pomodoro.start(forced_time)
140+
local work_duration
141+
if forced_time then
142+
work_duration = forced_time * MIN_IN_MS
143+
else
144+
work_duration = pomodoro.work_duration
145+
end
146+
info("Work session of " .. work_duration / MIN_IN_MS .. "m started!")
138147
pomodoro.phase = Phases.RUNNING
139-
pomodoro.startTimer(pomodoro.work_duration, pomodoro.startBreak)
148+
pomodoro.startTimer(work_duration, pomodoro.startBreak)
140149
end
141150

142151
function pomodoro.delayBreak()
@@ -159,13 +168,23 @@ function pomodoro.stop()
159168
end
160169

161170
function pomodoro.registerCmds()
162-
vim.api.nvim_create_user_command(
163-
"PomodoroForceBreak",
164-
pomodoro.startBreak,
165-
{}
166-
)
171+
vim.api.nvim_create_user_command("PomodoroForceBreak", function(opts)
172+
local forced_break_duration = tonumber(opts.args)
173+
if forced_break_duration then
174+
pomodoro.startBreak(forced_break_duration)
175+
else
176+
pomodoro.startBreak()
177+
end
178+
end, { nargs = "*" })
167179
vim.api.nvim_create_user_command("PomodoroSkipBreak", pomodoro.endBreak, {})
168-
vim.api.nvim_create_user_command("PomodoroStart", pomodoro.start, {})
180+
vim.api.nvim_create_user_command("PomodoroStart", function(opts)
181+
local forced_work_duration = tonumber(opts.args)
182+
if forced_work_duration then
183+
pomodoro.start(forced_work_duration)
184+
else
185+
pomodoro.start()
186+
end
187+
end, { nargs = "*" })
169188
vim.api.nvim_create_user_command("PomodoroStop", pomodoro.stop, {})
170189
vim.api.nvim_create_user_command(
171190
"PomodoroDelayBreak",

0 commit comments

Comments
 (0)