From c3d532e4df1391956113aebf02247597bab6a079 Mon Sep 17 00:00:00 2001 From: wu-json Date: Sat, 26 Sep 2026 15:49:01 -0700 Subject: [PATCH] feat(nvim): reserve note prefix for daily note shortcuts --- .github/workflows/test-neovim.yml | 2 ++ nvim/.config/nvim/lua/plugins/aesthetics.lua | 7 +++++ tests/daily-note.lua | 28 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/.github/workflows/test-neovim.yml b/.github/workflows/test-neovim.yml index b585fbd6..e6ce0016 100644 --- a/.github/workflows/test-neovim.yml +++ b/.github/workflows/test-neovim.yml @@ -5,6 +5,7 @@ on: paths: - 'nvim/.config/nvim/init.lua' - 'nvim/.config/nvim/lua/config/**' + - 'nvim/.config/nvim/lua/plugins/aesthetics.lua' - 'nvim/.config/nvim/lazy-lock.json' - 'tests/daily-note.lua' - '.github/workflows/test-neovim.yml' @@ -14,6 +15,7 @@ on: paths: - 'nvim/.config/nvim/init.lua' - 'nvim/.config/nvim/lua/config/**' + - 'nvim/.config/nvim/lua/plugins/aesthetics.lua' - 'nvim/.config/nvim/lazy-lock.json' - 'tests/daily-note.lua' - '.github/workflows/test-neovim.yml' diff --git a/nvim/.config/nvim/lua/plugins/aesthetics.lua b/nvim/.config/nvim/lua/plugins/aesthetics.lua index 76b7c262..40cb3c23 100644 --- a/nvim/.config/nvim/lua/plugins/aesthetics.lua +++ b/nvim/.config/nvim/lua/plugins/aesthetics.lua @@ -14,6 +14,13 @@ return { }, { "folke/snacks.nvim", + keys = function(_, keys) + for _, key in ipairs(keys) do + if key[1] == "n" then + key[1] = "nh" + end + end + end, opts = { dashboard = { sections = { diff --git a/tests/daily-note.lua b/tests/daily-note.lua index 988dbead..80b6e014 100644 --- a/tests/daily-note.lua +++ b/tests/daily-note.lua @@ -4,9 +4,24 @@ vim.opt.rtp:prepend(vim.env.SNACKS_TEST_DIR or vim.fn.stdpath("data") .. "/lazy/ require("snacks").setup({}) vim.o.hidden = true vim.o.columns = 140 +vim.g.mapleader = " " + +local history_opened = false +local keys = { + { "n", function() history_opened = true end, desc = "Notification History" }, +} +for _, plugin in ipairs(require("plugins.aesthetics")) do + if plugin[1] == "folke/snacks.nvim" then + plugin.keys(plugin, keys) + end +end +for _, key in ipairs(keys) do + vim.keymap.set("n", key[1], key[2], { desc = key.desc }) +end local directory = vim.fn.tempname() vim.fn.mkdir(directory, "p") +directory = vim.uv.fs_realpath(directory) -- Keep repository discovery outside these editor-state regression tests. vim.system = function() @@ -24,6 +39,11 @@ for _, map in ipairs(vim.api.nvim_get_keymap("n")) do end end assert(daily, "daily note mapping was not registered") +assert(vim.fn.maparg("n", "n") == "", "notification history still consumes the daily note prefix") + +local function press(keys) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(keys, true, false, true), "xt", false) +end local function assert_prose() assert(Snacks.zen.win and Snacks.zen.win:valid(), "prose window is missing") @@ -33,6 +53,14 @@ local function assert_prose() end local function run() + press("nh") + assert(history_opened, "notification history shortcut did not run") + history_opened = false + press("nd") + assert(not history_opened, "daily note shortcut opened notification history") + assert(vim.api.nvim_buf_get_name(0) == directory .. "/" .. os.date("%Y-%m-%d.md"), "daily note shortcut did not open today's note") + assert_prose() + Snacks.zen.win:close() vim.api.nvim_cmd({ cmd = "edit", args = { directory .. "/" .. os.date("%Y-%m-%d.md") } }, {}) local note = vim.api.nvim_get_current_buf() vim.api.nvim_buf_set_lines(note, 0, -1, false, { "unsaved daily note" })