nvim: Fix zk commands always being created

They were under a conditional which would only have them be created if
which-key plugin was found beforehand.
This commit is contained in:
Marty Oehme 2025-03-08 19:32:50 +01:00
parent 2eebe047f6
commit 15cf9b192b
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -168,39 +168,49 @@ local prose_plugs = {
-- bring zettelkasten commands
{
"zk-org/zk-nvim",
config = function()
opts = function()
if require("core.util").is_available("which-key") then
require("which-key").add({
{ "<leader>n", group = "notes" },
{ "<localleader>n", group = "note" },
{ "<localleader>n", group = "note", mode = "v" },
})
end
require("zk.commands").add("ZkOrphans", function(opts)
opts = vim.tbl_extend("force", { orphan = true }, opts or {})
require("zk").edit(opts, { title = "Zk Orphans" })
end)
require("zk.commands").add("ZkGrep", function(opts)
local collection = {}
local list_opts = { select = { "title", "path", "absPath" } }
require("zk.api").list(vim.env.ZK_NOTEBOOK_DIR, list_opts, function(_, notes)
for _, note in ipairs(notes) do
collection[note.absPath] = note.title or note.path
end
end)
local options = vim.tbl_deep_extend("force", {
prompt_title = "Notes",
search_dirs = { vim.env.ZK_NOTEBOOK_DIR },
disable_coordinates = true,
path_display = function(_, path)
return collection[path]
end,
}, opts or {})
require("telescope.builtin").live_grep(options)
require("zk.commands").add("ZkOrphans", function(opts)
opts = vim.tbl_extend("force", { orphan = true }, opts or {})
require("zk").edit(opts, { title = "Zk Orphans" })
end)
require("zk.commands").add("ZkGrep", function(opts)
local collection = {}
local list_opts = { select = { "title", "path", "absPath" } }
require("zk.api").list(vim.env.ZK_NOTEBOOK_DIR, list_opts, function(_, notes)
for _, note in ipairs(notes) do
collection[note.absPath] = note.title or note.path
end
end)
local search_dir = vim.env.ZK_NOTEBOOK_DIR
local options = vim.tbl_deep_extend("force", {
prompt = "Note Grep ",
-- cmd = "cd " .. search_dir .. "; rg --vimgrep",
cwd = search_dir,
disable_coordinates = true,
path_display = function(_, path)
return collection[path]
end,
}, opts or {})
-- FIXME: Don't hard-code this so much?
-- require("telescope.builtin").live_grep(options)
require("fzf-lua").live_grep(options)
end)
local picker = "select"
if require("core.util").is_available("fzf-lua") then
picker = "fzf_lua"
elseif require("core.util").is_available("telescope") then
picker = "telescope"
end
require("zk").setup({
picker = "telescope",
picker = picker,
lsp = {
auto_attach = {
enabled = true,