Skip to content

fix: =$= and =0= motions for calendar view #987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lua/orgmode/objects/calendar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ function Calendar:open()
vim.keymap.set('n', '<Left>', function()
return self:cursor_left()
end, map_opts)
vim.keymap.set('n', '0', function()
return self:beginning()
end, map_opts)
vim.keymap.set('n', '$', function()
return self:ending()
end, map_opts)
vim.keymap.set('n', '<Right>', function()
return self:cursor_right()
end, map_opts)
Expand Down Expand Up @@ -436,6 +442,27 @@ function Calendar:cursor_left()
self:render()
end

function Calendar:beginning()
if self.select_state ~= SelState.DAY then
return
end
local line = vim.fn.line('.')
vim.fn.cursor(line, vim.fn.getline('.'):match('^%s*'):len() + 1)
self.date = self:get_selected_date()
self:render()
end

function Calendar:ending()
if self.select_state ~= SelState.DAY then
return
end
local line = vim.fn.line('.')
local line_no_trailing_space = vim.fn.getline('.'):gsub('%s*$', '')
vim.fn.cursor(line, line_no_trailing_space:len())
self.date = self:get_selected_date()
self:render()
end

---@param direction string
---@param step_size number
---@param current number
Expand Down