Skip to content

Commit

Permalink
feature: enhance calendar widget with time picker (nvim-orgmode#650)
Browse files Browse the repository at this point in the history
* feat: implement time picker

To make it more convenient to scheduled dates with particular times extends the
existing date picker with a time picker.

- t adds a time and jumps to the time picker
- j and k decrease or increase the time, counts are supported
- h and l determine if the time is shifted about an hour, 10 minutes or
  5 minutes
- T clears the time
- Esc leaves the time picker first and pressed secondly the date picker

* feat(date): add default to 'Enter date'

When entering the date via direct input, provide the currently selected
date as default value.

* chore: fix warnings in calendar

* fix: jump to descrete 10 or 5 minute steps

When adjusting an odd minute value, we first want to jump to the next
flat 10 or 5 minute value.

* feat: make minute steps configurable

Because it's a matter of preference, in which steps the user want's to
jump through minutes, we make it configurable.

* feat: highlight currently selected date

* refactor: extract date highlighting into function

* feat: update date selection regularly

* feat: round minutes on adjusting hours

* fix: show time picker also when changing date

* fix: enable clear time keymap consistently

To be able to clear times if no timestamp was set when the picker was
loaded, we need to set the clear-time keymapping during rerendering of
time.

* refactor: integrate highlights into new function

* fix: allow to switch back to day selection

* feat: overhaul config options

- wrap everything into calendar
- cleanup names
- use boolean "start_from_sunday"

* doc: add some docs for the config options

* doc: fix typo

---------

Co-authored-by: Sebastian Flügge <[email protected]>
  • Loading branch information
seflue and seflue authored May 28, 2024
1 parent fb6afdd commit 615bb91
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 24 deletions.
27 changes: 25 additions & 2 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
2. [Settings](#settings)
1. [Global settings](#global-settings)
2. [Agenda settings](#agenda-settings)
3. [Tags settings](#tags-settings)
3. [Calendar settings](#calendar-settings)
4. [Tags settings](#tags-settings)
3. [Mappings](#mappings)
1. [Global mappings](#global-mappings)
2. [Agenda mappings](#agenda-mappings)
Expand Down Expand Up @@ -677,6 +678,28 @@ Additional files to search from agenda search prompt.<br />
Currently it accepts only a single value: `agenda-archives`.<br />
Example value: `{'agenda-archives'}`

### Calendar settings

Adjust behavior of the calendar modal (ex: [changing the date under cursor](#org_change_date)).

#### **calendar.round_min_with_hours**

_type_: `boolean`<br />
_default_: `true`<br />
Should minutes be rounded, when the hour is changed. It behaves more fluently when changing the hours, especially when scheduling from the current time (which can be something odd). If set to false, the minutes are unchanged while changing the hours.

#### **calendar.min_big_step**

_type_: `number`<br />
_default_: `15`<br />
The step size for changing the minutes while the cursor is on the first digit.

#### **calendar.min_small_step**

_type_: `number`<br />
_default_: same as [](#org_time_stamp_rounding_minutes)<br />
The step size for changing the minutes while the cursor is on the second digit.

### Tags settings

#### **org_tags_column**
Expand Down Expand Up @@ -1712,7 +1735,7 @@ This option is most optimized because it doesn't load plugins and your init.vim
For **MacOS**, things should be very similar, but I wasn't able to test it. Any help on this is appreciated.

## Clocking
There is partial suport for [Clocking work time](https://orgmode.org/manual/Clocking-Work-Time.html).<br />
There is partial support for [Clocking work time](https://orgmode.org/manual/Clocking-Work-Time.html).<br />
Supported actions:
##### Clock in
Org file mapping: `<leader>oxi`<br />
Expand Down
5 changes: 5 additions & 0 deletions lua/orgmode/config/defaults.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---@class OrgDefaultConfig
---@field org_id_method 'uuid' | 'ts' | 'org'
---@field org_agenda_span 'day' | 'week' | 'month' | 'year' | number
---@field calendar { round_min_with_hours: boolean, min_big_step: number, min_small_step: number? }
local DefaultConfig = {
org_agenda_files = '',
org_default_notes_file = '',
Expand All @@ -13,6 +14,10 @@ local DefaultConfig = {
org_agenda_start_on_weekday = 1,
org_agenda_start_day = nil, -- start from today + this modifier
calendar_week_start_day = 1,
calendar = {
round_min_with_hours = true,
min_big_step = 15,
},
org_capture_templates = {
t = {
description = 'Task',
Expand Down
Loading

0 comments on commit 615bb91

Please sign in to comment.