Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ return {
require('calendar').setup({
mark_icon = '•',
-- locale currently affects UI language only.
locale = 'en-US', -- en-US or zh-CN
locale = 'en-US', -- en-US or zh-CN or ja-JP
show_adjacent_days = true,
-- calendar.nvim support vim style keyboard navigation, hjkl.
keymap = {
Expand Down
1 change: 1 addition & 0 deletions lua/calendar/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local default_config = {
next_week = 'j',
previous_week = 'k',
today = 't',
close = 'q',
},
mark_icon = '•',
show_adjacent_days = true,
Expand Down
7 changes: 6 additions & 1 deletion lua/calendar/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local function render_lines(year, month, grid)
lines,
string.format('%17s %04d ', months[month], year)
)
elseif locale == 'zh-CN' then
elseif locale == 'zh-CN' or locale == 'ja-JP' then
table.insert(
lines,
string.format(' %04d 年 %2d 月 ', year, month)
Expand All @@ -50,6 +50,8 @@ local function render_lines(year, month, grid)
table.insert(lines, ' Mon Tue Wed Thu Fri Sat Sun ')
elseif locale == 'zh-CN' then
table.insert(lines, ' 一 二 三 四 五 六 日 ')
elseif locale == 'ja-JP' then
table.insert(lines, ' 月 火 水 木 金 土 日 ')
else
table.insert(lines, ' Mon Tue Wed Thu Fri Sat Sun ')
end
Expand Down Expand Up @@ -209,6 +211,9 @@ function M.open(year, month, day)
vim.api.nvim_buf_set_keymap(buf, 'n', conf.keymap.today, '', {
callback = M.today,
})
vim.api.nvim_buf_set_keymap(buf, 'n', conf.keymap.close, '', {
callback = M.close,
})
vim.api.nvim_buf_set_keymap(buf, 'n', '<LeftMouse>', '', {
callback = function()
local pos = vim.fn.getmousepos()
Expand Down