hephaestus/heph.nvim/lua/heph/init.lua
Erich Blume cdd4d9f62a
All checks were successful
Build / validate (pull_request) Successful in 10m44s
heph.nvim: rip out auto-spawn — connect-only plugin
The daemon is now an OS service (`heph daemon`); the plugin no longer spawns or
supervises one. Removes the managed-daemon machinery entirely.

- delete lua/heph/daemon.lua (spawn/ensure/stop_spawned/self-heal)
- init.lua: connect-only; probe `health` once and guide to `heph daemon start`
- rpc.lua: drop set_respawn + respawn-on-drop; a dropped connection just
  reconnects once (e.g. after `heph daemon restart`), never spawns
- config.lua: drop autostart/bin/db; stable socket fallback (data-dir, matches
  hephd::default_socket_path), keep $HEPH_SOCKET for dev isolation
- tests: spawn/wait_ready move into the e2e harness (test infra); rework
  managed_daemon_spec into a connect-only spec (connect / clean-fail / reconnect)

16 nvim e2e specs pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 21:21:28 -07:00

43 lines
1.4 KiB
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.
---
--- The plugin is **connect-only** — it never spawns or supervises a `hephd`.
--- Run the daemon as an OS service with `heph daemon start` ([[run-the-daemon]]);
--- this just connects to it. If nothing is serving the socket, we notify once
--- with guidance and let later calls retry (a plain reconnect, never a spawn).
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
local rpc = require("heph.rpc")
rpc.setup(cfg.socket)
-- A cheap liveness probe so a missing daemon is reported up front, not as a
-- cryptic error on the first command.
local ok = pcall(function()
rpc.call("health", {})
end)
if not ok then
require("heph.util").notify(
"no hephd at " .. cfg.socket .. " — run `heph daemon start`",
vim.log.levels.WARN
)
end
config.apply_keymaps(cfg)
return M
end
return M