generated from eblume/project-template
39 lines
1.1 KiB
Lua
39 lines
1.1 KiB
Lua
|
|
--- Configuration defaults, socket resolution, and default keymaps.
|
||
|
|
|
||
|
|
local M = {}
|
||
|
|
|
||
|
|
M.defaults = {
|
||
|
|
--- Path to hephd's unix socket. `nil` → resolved to the daemon default.
|
||
|
|
socket = nil,
|
||
|
|
--- Spawn a local hephd if the socket is not ready (off by default in v1).
|
||
|
|
autostart = false,
|
||
|
|
--- hephd binary for autostart.
|
||
|
|
bin = "hephd",
|
||
|
|
--- Set the default `<leader>h*` keymaps. `false` to opt out.
|
||
|
|
keymaps = true,
|
||
|
|
}
|
||
|
|
|
||
|
|
--- Resolve the socket path, mirroring hephd's `default_socket_path`:
|
||
|
|
--- `$XDG_RUNTIME_DIR/heph/hephd.sock`, falling back to the temp dir.
|
||
|
|
function M.resolve_socket(opt)
|
||
|
|
if opt and #opt > 0 then
|
||
|
|
return opt
|
||
|
|
end
|
||
|
|
local xdg = vim.env.XDG_RUNTIME_DIR
|
||
|
|
local base = (xdg and #xdg > 0) and xdg or (vim.env.TMPDIR or "/tmp")
|
||
|
|
return (base:gsub("/+$", "")) .. "/heph/hephd.sock"
|
||
|
|
end
|
||
|
|
|
||
|
|
--- Apply the default keymaps (no-op when `opts.keymaps` is false).
|
||
|
|
function M.apply_keymaps(opts)
|
||
|
|
if not opts.keymaps then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
local map = vim.keymap.set
|
||
|
|
map("n", "<leader>hj", function()
|
||
|
|
require("heph.journal").open()
|
||
|
|
end, { desc = "heph: today's journal" })
|
||
|
|
-- Task/agenda maps are added with their views in slice 11b.
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|