Skip to content

Commit 98f8319

Browse files
committed
feat: support <LeftMouse> keymap
1 parent 62a83c2 commit 98f8319

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

lua/calendar/view.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ function M.open(year, month, day)
130130
vim.api.nvim_buf_set_keymap(buf, 'n', conf.keymap.today, '', {
131131
callback = M.today,
132132
})
133+
vim.api.nvim_buf_set_keymap(buf, 'n', '<LeftMouse>', '', {
134+
callback = function()
135+
local pos = vim.fn.getmousepos()
136+
if pos.winid == win then
137+
vim.api.nvim_win_set_cursor(win, { pos.line, pos.column - 1 })
138+
local line = vim.fn.line('.')
139+
if line >= 4 then
140+
local mouse_day = tonumber(vim.fn.expand('<cword>'))
141+
if mouse_day then
142+
M.highlight_day(mouse_day)
143+
end
144+
end
145+
end
146+
end,
147+
})
133148
end
134149
vim.bo[buf].modifiable = true
135150
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)

0 commit comments

Comments
 (0)