File tree 3 files changed +19
-4
lines changed
3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,13 @@ function OrgAgendaType:new(opts)
69
69
to = nil ,
70
70
clock_report = nil ,
71
71
show_clock_report = opts .show_clock_report or false ,
72
- start_on_weekday = opts .start_on_weekday or config .org_agenda_start_on_weekday ,
73
- start_day = opts .start_day or config .org_agenda_start_day ,
72
+ start_on_weekday = utils . if_nil ( opts .start_on_weekday , config .org_agenda_start_on_weekday ) ,
73
+ start_day = utils . if_nil ( opts .start_day , config .org_agenda_start_day ) ,
74
74
agenda_files = opts .agenda_files ,
75
75
header = opts .header ,
76
76
sorting_strategy = opts .sorting_strategy or vim .tbl_get (config .org_agenda_sorting_strategy , ' agenda' ) or {},
77
77
id = opts .id ,
78
- remove_tags = type (opts .remove_tags ) == ' boolean ' and opts . remove_tags or config .org_agenda_remove_tags ,
78
+ remove_tags = utils . if_nil (opts .remove_tags , config .org_agenda_remove_tags ) ,
79
79
}
80
80
data .valid_filters = vim .tbl_filter (function (filter )
81
81
return filter and true or false
Original file line number Diff line number Diff line change 13
13
--- @class OrgAgendaCustomCommandAgenda : OrgAgendaCustomCommandTypeInterface
14
14
--- @field org_agenda_span ? OrgAgendaSpan Default : ' week'
15
15
--- @field org_agenda_start_day ? string Modifier from today , example ' +1d'
16
- --- @field org_agenda_start_on_weekday ? number
16
+ --- @field org_agenda_start_on_weekday ? number | false
17
17
18
18
--- @class OrgAgendaCustomCommandTags : OrgAgendaCustomCommandTypeInterface
19
19
--- @field match ? string
Original file line number Diff line number Diff line change @@ -635,4 +635,19 @@ function utils.notify(msg, opts)
635
635
vim .notify (message , vim .log .levels [opts .level :upper ()], opts )
636
636
end
637
637
638
+ --- Return first non-nil value
639
+ --- @generic T
640
+ --- @param ... T
641
+ --- @return T
642
+ function utils .if_nil (...)
643
+ local nargs = select (' #' , ... )
644
+ for i = 1 , nargs do
645
+ local v = select (i , ... )
646
+ if v ~= nil then
647
+ return v
648
+ end
649
+ end
650
+ return nil
651
+ end
652
+
638
653
return utils
You can’t perform that action at this time.
0 commit comments