Skip to content

Commit 12680a3

Browse files
fix: =$= and =0= motions for calendar view (#987)
* fix: config =$= and =0= motions for calendar view * fix: line string beginning index Co-authored-by: Kristijan Husak <[email protected]> * fix: line string ending index Co-authored-by: Kristijan Husak <[email protected]> --------- Co-authored-by: Kristijan Husak <[email protected]>
1 parent 3c8319f commit 12680a3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lua/orgmode/objects/calendar.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ function Calendar:open()
130130
vim.keymap.set('n', '<Left>', function()
131131
return self:cursor_left()
132132
end, map_opts)
133+
vim.keymap.set('n', '0', function()
134+
return self:beginning()
135+
end, map_opts)
136+
vim.keymap.set('n', '$', function()
137+
return self:ending()
138+
end, map_opts)
133139
vim.keymap.set('n', '<Right>', function()
134140
return self:cursor_right()
135141
end, map_opts)
@@ -436,6 +442,27 @@ function Calendar:cursor_left()
436442
self:render()
437443
end
438444

445+
function Calendar:beginning()
446+
if self.select_state ~= SelState.DAY then
447+
return
448+
end
449+
local line = vim.fn.line('.')
450+
vim.fn.cursor(line, vim.fn.getline('.'):match('^%s*'):len() + 1)
451+
self.date = self:get_selected_date()
452+
self:render()
453+
end
454+
455+
function Calendar:ending()
456+
if self.select_state ~= SelState.DAY then
457+
return
458+
end
459+
local line = vim.fn.line('.')
460+
local line_no_trailing_space = vim.fn.getline('.'):gsub('%s*$', '')
461+
vim.fn.cursor(line, line_no_trailing_space:len())
462+
self.date = self:get_selected_date()
463+
self:render()
464+
end
465+
439466
---@param direction string
440467
---@param step_size number
441468
---@param current number

0 commit comments

Comments
 (0)