diff --git a/home/profiles/nvim/default.nix b/home/profiles/nvim/default.nix index 4fad51c..6b2cb91 100644 --- a/home/profiles/nvim/default.nix +++ b/home/profiles/nvim/default.nix @@ -330,14 +330,14 @@ in nnoremap gc :G commit -v -q %:p " kitaab - map cz :VimwikiIndex:ZettelNew - map zs :ZettelSearch - map zn :ZettelNew - map zo :ZettelOpen - map zf :Telescope oldfiles only_cwd=true - map wt :VimwikiMakeTomorrowDiaryNote - map wd :VimwikiMakeYesterdayDiaryNote - map zm :ZenMode:setlocal nospell + "map cz :VimwikiIndex:ZettelNew + "map zs :ZettelSearch + "map zn :ZettelNew + "map zo :ZettelOpen + "map zf :Telescope oldfiles only_cwd=true + "map wt :VimwikiMakeTomorrowDiaryNote + "map wd :VimwikiMakeYesterdayDiaryNote + "map zm :ZenMode:setlocal nospell let g:vimwiki_list = [{ 'path': '~/kitaab/vimwiki', 'auto_tags': 1, 'auto_diary_index': 1, 'auto_generate_links': 1 }] let g:sync_taskwarrior = 0 let g:zettel_format = "%y%m%d-%H%M" @@ -802,6 +802,39 @@ in -- zk require("zk").setup() + vim.api.nvim_set_keymap("n", "zn", "ZkNew { title = vim.fn.input('Title: ') }", opts) + + -- Open notes. + vim.api.nvim_set_keymap("n", "zo", "ZkNotes { sort = { 'modified' } }", opts) + -- Open notes associated with the selected tags. + vim.api.nvim_set_keymap("n", "zt", "ZkTags", opts) + + local map = vim.api.nvim_set_keymap + -- Search for the notes matching a given query. + vim.api.nvim_set_keymap("n", "zf", "ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }", opts) + -- Search for the notes matching the current visual selection. + vim.api.nvim_set_keymap("v", "zf", ":'<,'>ZkMatch", opts) + map("n", "", "lua vim.lsp.buf.definition()", opts) + + -- Create a new note after asking for its title. + -- This overrides the global `zn` mapping to create the note in the same directory as the current buffer. + map("n", "zn", "ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", opts) + -- Create a new note in the same directory as the current buffer, using the current selection for title. + map("v", "znt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }", opts) + -- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title. + map("v", "znc", ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", opts) + + -- Open notes linking to the current buffer. + map("n", "zb", "ZkBacklinks", opts) + -- Alternative for backlinks using pure LSP and showing the source context. + --map('n', 'zb', 'lua vim.lsp.buf.references()', opts) + -- Open notes linked by the current buffer. + map("n", "zl", "ZkLinks", opts) + + -- Preview a linked note. + map("n", "K", "lua vim.lsp.buf.hover()", opts) + -- Open the code actions for a visual selection. + map("v", "za", ":'<,'>lua vim.lsp.buf.range_code_action()", opts) -- zen mode require('zen-mode').setup{