Skip to content

Commit fbf960a

Browse files
Add support to start week from Sunday in calendar modal. Closes #390
1 parent 5ef1041 commit fbf960a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

DOCS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ Determine if blank line should be prepended when:
302302
* Adding heading via `org_meta_return` and `org_insert_*` mappings
303303
* Adding a list item via `org_meta_return`
304304

305+
#### **calendar_week_start_day**
306+
*type*: `number`<br />
307+
*default value*: `1`<br />
308+
Available options:
309+
* `0` - start week on Sunday
310+
* `1` - start week on Monday
311+
312+
Determine on which day the week will start in calendar modal (ex: [changing the date under cursor](#org_change_date))
313+
305314
#### **emacs_config**
306315
*type*: `table`<br />
307316
*default value*: `{ executable_path = 'emacs', configure_path='$HOME/.emacs.d/init.el' }`<br />

lua/orgmode/config/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ return {
88
org_agenda_span = 'week', -- day/week/month/year/number of days
99
org_agenda_start_on_weekday = 1,
1010
org_agenda_start_day = nil, -- start from today + this modifier
11+
calendar_week_start_day = 1,
1112
org_capture_templates = {
1213
t = {
1314
description = 'Task',

lua/orgmode/objects/calendar.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local Date = require('orgmode.objects.date')
22
local utils = require('orgmode.utils')
33
local Promise = require('orgmode.utils.promise')
4+
local config = require('orgmode.config')
45
---@class Calendar
56
---@field win number
67
---@field buf number
@@ -88,10 +89,17 @@ end
8889

8990
function Calendar.render()
9091
vim.api.nvim_buf_set_option(Calendar.buf, 'modifiable', true)
92+
local start_from_sunday = config.calendar_week_start_day == 0
9193

9294
local first_row = { 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' }
95+
if start_from_sunday then
96+
first_row = { 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' }
97+
end
9398
local content = { {}, {}, {}, {}, {}, {} }
9499
local start_weekday = Calendar.month:get_isoweekday()
100+
if start_from_sunday then
101+
start_weekday = Calendar.month:get_weekday()
102+
end
95103
while start_weekday > 1 do
96104
table.insert(content[1], ' ')
97105
start_weekday = start_weekday - 1

0 commit comments

Comments
 (0)