if require("zk.util").notebook_root(vim.fn.expand("%:p")) ~= nil then vim.keymap.set("n", "", vim.lsp.buf.definition, { buffer = true, noremap = true, silent = false, desc = "Open the link under the caret." }) -- Create a new note in the same directory as the current buffer, using the current selection for title. vim.keymap.set("v", "zn", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }", { buffer = true, noremap = true, silent = false, desc = "Create a new note using the current selection for title." }) -- Create a new note in the same directory as the current buffer, -- using the current selection for note content and asking for its title. vim.keymap.set("v", "zN", ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", { buffer = true, noremap = true, silent = false, desc = "Create a new note using the current selection for contents." }) vim.keymap.set("n", "zb", "ZkBacklinks", { buffer = true, noremap = true, silent = false, desc = "Open notes linking to the current buffer." }) -- Alternative for backlinks using pure LSP and showing the source context. -- The results will appear in the quickfix list. vim.keymap.set("n", "zB", vim.lsp.buf.references, { buffer = true, noremap = true, silent = false, desc = "Open notes linking to the current buffer with LSP." }) vim.keymap.set("n", "zl", "ZkLinks", { buffer = true, noremap = true, silent = false, desc = "Open notes linked by the current buffer." }) end