generated from eblume/project-template
33 lines
1,022 B
Lua
33 lines
1,022 B
Lua
|
|
--- heph.nvim — the primary surface for hephaestus (tech-spec §8): an
|
||
|
|
--- obsidian.nvim replacement that is a thin client of the local `hephd` over
|
||
|
|
--- its unix-socket JSON-RPC. This module is the public entry point.
|
||
|
|
|
||
|
|
local config = require("heph.config")
|
||
|
|
|
||
|
|
local M = {}
|
||
|
|
|
||
|
|
--- The resolved config from the last `setup` (nil before setup).
|
||
|
|
M.config = nil
|
||
|
|
|
||
|
|
--- Configure the plugin. `opts.socket` overrides the daemon socket path;
|
||
|
|
--- `opts.keymaps = false` disables the default keymaps. Idempotent.
|
||
|
|
function M.setup(opts)
|
||
|
|
local cfg = vim.tbl_deep_extend("force", config.defaults, opts or {})
|
||
|
|
cfg.socket = config.resolve_socket(cfg.socket)
|
||
|
|
M.config = cfg
|
||
|
|
|
||
|
|
require("heph.rpc").setup(cfg.socket)
|
||
|
|
|
||
|
|
if cfg.autostart then
|
||
|
|
local ok = require("heph.daemon").wait_ready(cfg.socket, 500)
|
||
|
|
if not ok then
|
||
|
|
require("heph.daemon").spawn({ bin = cfg.bin, socket = cfg.socket, db = nil })
|
||
|
|
require("heph.daemon").wait_ready(cfg.socket, 5000)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
config.apply_keymaps(cfg)
|
||
|
|
return M
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|