hephaestus/heph.nvim/lua/heph/journal.lua

19 lines
546 B
Lua
Raw Normal View History

--- Daily journal (tech-spec §8). `journal.open_or_create` is idempotent (the
--- node id is deterministic in (owner, date)), so opening today's note twice is
--- safe.
local rpc = require("heph.rpc")
local util = require("heph.util")
local M = {}
--- Open (creating if absent) the journal for `date` (default: today), in a
--- buffer. Returns the node.
function M.open(date)
date = date or util.iso_today()
local node = rpc.call("journal.open_or_create", { date = date })
require("heph.node").open(node.id)
return node
end
return M