local zk_status_ok, zk = pcall(require, "zk") if not zk_status_ok then return end zk.setup({ picker = "telescope", lsp = { -- `config` is passed to `vim.lsp.start_client(config)` config = { cmd = { "zk", "lsp" }, name = "zk", -- on_attach = ... -- etc, see `:h vim.lsp.start_client()` }, -- automatically attach buffers in a zk notebook that match the given filetypes auto_attach = { enabled = true, filetypes = { "markdown" }, }, }, }) local opts = { noremap=true, silent=false } -- Create a new note after asking for its title. vim.api.nvim_set_keymap("n", "zl", "ZkNew { title = vim.fn.input('Title (litterature): '), dir = 'litterature'}", opts) vim.api.nvim_set_keymap("n", "zs", "ZkNew { title = vim.fn.input('Title (slipbox): '), dir = 'slipbox'}", opts) vim.api.nvim_set_keymap("v", "zs", ":'<,'>ZkNewFromTitleSelection { dir = 'slipbox'}", opts) vim.api.nvim_set_keymap("n", "zi", "ZkNew { title = vim.fn.input('Title (inbox): '), dir = 'inbox'}", opts) vim.api.nvim_set_keymap("v", "zi", ":'<,'>ZkNewFromTitleSelection { dir = 'inbox'}", opts) vim.api.nvim_set_keymap("n", "zh", "ZkNew { title = vim.fn.input('Title (hubs): '), dir = 'hubs'}", 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) -- 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) -- Open notes linking to the current buffer. vim.api.nvim_set_keymap("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. vim.api.nvim_set_keymap("n", "zL", "ZkLinks", opts) -- Preview a linked note. vim.api.nvim_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) -- Open the code actions for a visual selection. vim.api.nvim_set_keymap("v", "za", ":'<,'>lua vim.lsp.buf.code_action()", opts)