-
Verify
How can we help you?My daily notes are in the directory How can I do this inside Neovim? I tried with the Thanks in advance for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Using the API, I came out with this solution: local commands = require("zk.commands")
commands.add("ZkDir", function(options)
options = options or {}
local dir = options.dir or "journal/daily"
require("zk.api").list(nil, {
select = { "absPath", "path", "title", "created", "modified" },
}, function(err, notes)
if err then
vim.notify("Error fetching notes: " .. vim.inspect(err), vim.log.levels.ERROR)
return
end
-- Filter notes after retrieval and ensure valid paths
local filtered_notes = {}
for _, note in ipairs(notes) do
-- Check both that path exists and matches our directory
if note.path and type(note.path) == "string" and string.match(note.path, dir .. "/") then
table.insert(filtered_notes, note)
end
end
if #filtered_notes == 0 then
vim.notify("No notes found in directory", vim.log.levels.INFO)
return
end
-- sort filtered notes
table.sort(filtered_notes, function(a, b)
return a.created > b.created
end)
-- Use the picker to display filtered results
require("zk.ui").pick_notes(filtered_notes, { title = "Journal Notes" }, function(selected_notes)
if selected_notes and #selected_notes > 0 then
for _, note in ipairs(selected_notes) do
vim.cmd("edit " .. note.absPath)
end
end
end)
end)
end)Then I can use If there is a simpler approach though, would love to hear about it. |
Beta Was this translation helpful? Give feedback.
Using the API, I came out with this solution: