zk.lua (1058B)
1 local M = {} 2 3 local keybind = function() 4 vim.keymap.set('n', '<leader>zc', '<cmd>ZkNew<cr>', {noremap = true}) 5 vim.keymap.set('x', '<leader>zc', '<cmd>ZkNewFromTitleSelection<cr>', {noremap = true}) 6 vim.keymap.set('n', '<space>zn', '<cmd>ZkNotes<cr>', {noremap = true}) 7 vim.keymap.set('n', '<space>zt', '<cmd>ZkTags<cr>', {noremap = true}) 8 vim.keymap.set('n', '<space>zl', '<cmd>ZkLinks<cr>', {noremap = true}) 9 vim.keymap.set('n', '<space>zo', '<cmd>ZkNotes {orphan = true}<cr>', {noremap = true}) 10 end 11 12 M.setup = function(lsp_cfg) 13 lsp_cfg = lsp_cfg or {} 14 require('zk').setup({lsp = {config = lsp_cfg}}) 15 require('telescope').load_extension('zk') 16 keybind() 17 end 18 19 local make_lsp_location = function() 20 local params = vim.lsp.util.make_range_params() 21 params.uri = params.textDocument.uri 22 params.textDocument = nil 23 return params 24 end 25 26 M.new_link = function() 27 vim.ui.input('title', function(title) 28 local location = make_lsp_location() 29 require('zk').new(nil, {insertLinkAtLocation = location, title = title}) 30 end) 31 end 32 33 return M