57 lines
2.5 KiB
Lua
57 lines
2.5 KiB
Lua
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", "<leader>zl", "<Cmd>ZkNew { title = vim.fn.input('Title (litterature): '), dir = 'litterature'}<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "<leader>zs", "<Cmd>ZkNew { title = vim.fn.input('Title (slipbox): '), dir = 'slipbox'}<CR>", opts)
|
|
vim.api.nvim_set_keymap("v", "<leader>zs", ":'<,'>ZkNewFromTitleSelection { dir = 'slipbox'}<CR>", opts)
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>zi", "<Cmd>ZkNew { title = vim.fn.input('Title (inbox): '), dir = 'inbox'}<CR>", opts)
|
|
vim.api.nvim_set_keymap("v", "<leader>zi", ":'<,'>ZkNewFromTitleSelection { dir = 'inbox'}<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "<leader>zh", "<Cmd>ZkNew { title = vim.fn.input('Title (hubs): '), dir = 'hubs'}<CR>", opts)
|
|
|
|
-- Open notes.
|
|
vim.api.nvim_set_keymap("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", opts)
|
|
-- Open notes associated with the selected tags.
|
|
vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", opts)
|
|
|
|
-- Search for the notes matching a given query.
|
|
vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }<CR>", opts)
|
|
-- Search for the notes matching the current visual selection.
|
|
vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", opts)
|
|
|
|
-- Open notes linking to the current buffer.
|
|
vim.api.nvim_set_keymap("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", opts)
|
|
-- Alternative for backlinks using pure LSP and showing the source context.
|
|
--map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
-- Open notes linked by the current buffer.
|
|
vim.api.nvim_set_keymap("n", "<leader>zL", "<Cmd>ZkLinks<CR>", opts)
|
|
|
|
-- Preview a linked note.
|
|
vim.api.nvim_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
-- Open the code actions for a visual selection.
|
|
vim.api.nvim_set_keymap("v", "<leader>za", ":'<,'>lua vim.lsp.buf.code_action()<CR>", opts)
|