config/.config/nvim/lua/lazyvim/plugins/zk.lua
2025-01-07 12:56:43 +10:30

34 lines
1.1 KiB
Lua

return {
{
"mickael-menu/zk-nvim",
enabled = true,
event = "VeryLazy",
opts = {
picker = "telescope",
},
config = function(_, opts)
require("zk").setup(opts)
local function yankName(options, picker_options)
require("zk").pick_notes(options, picker_options, function(notes)
local pos = vim.api.nvim_win_get_cursor(0)[2]
local line = vim.api.nvim_get_current_line()
if picker_options.multi_select == false then
notes = { notes }
end
for _, note in ipairs(notes) do
-- stylua: ignore
local nline = line:sub(0, pos) .. note.title .. " - " .. note.path .. line:sub(pos + 1)
vim.api.nvim_set_current_line(nline)
end
end)
end
require("zk.commands").add("ZkInsertLink", function(options)
yankName(options, { title = "Zk Yank" })
end)
end,
},
}