heph.nvim: rip out auto-spawn — connect-only plugin
All checks were successful
Build / validate (pull_request) Successful in 10m44s

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>
This commit is contained in:
Erich Blume 2026-06-02 21:21:28 -07:00
commit cdd4d9f62a
6 changed files with 114 additions and 308 deletions

View file

@ -4,15 +4,8 @@ local M = {}
M.defaults = {
--- Path to hephd's unix socket. `nil` → `$HEPH_SOCKET`, else the daemon default.
--- The plugin is connect-only; run the daemon with `heph daemon start`.
socket = nil,
--- DB path for an autostarted local daemon. `nil` → `$HEPH_DB`, else hephd's default.
db = nil,
--- Plug-and-play: spawn (and manage) a local hephd when none is serving
--- `socket`. Set `false` when you run your own daemon (server/client): the
--- plugin then connects only, and warns if nothing is reachable.
autostart = true,
--- hephd binary for autostart (on PATH for an installed heph).
bin = "hephd",
--- Title of the home / index page (`:Heph home`).
home = "Home",
--- How many recent days the `:Heph journals` picker offers.
@ -22,27 +15,24 @@ M.defaults = {
}
--- Resolve the socket path: explicit opt, then `$HEPH_SOCKET`, then hephd's
--- default (`$XDG_RUNTIME_DIR/heph/hephd.sock`, temp-dir fallback). The env knob
--- lets a dev Neovim target a `mise run dev` daemon without touching real data.
--- default — `$XDG_RUNTIME_DIR/heph/hephd.sock`, else a **stable**
--- `<data-dir>/heph/hephd.sock` (matching `hephd::default_socket_path`; not a
--- temp dir, since the daemon is a persistent service). `$HEPH_SOCKET` lets a
--- dev Neovim target a `mise run dev` daemon without touching real data.
function M.resolve_socket(opt)
opt = (opt and #opt > 0) and opt or vim.env.HEPH_SOCKET
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
--- Resolve the DB path for an autostarted daemon: explicit opt, then `$HEPH_DB`,
--- else nil (let hephd pick its default). Pairs with `resolve_socket` for dev
--- isolation.
function M.resolve_db(opt)
opt = (opt and #opt > 0) and opt or vim.env.HEPH_DB
if opt and #opt > 0 then
return opt
if xdg and #xdg > 0 then
return (xdg:gsub("/+$", "")) .. "/heph/hephd.sock"
end
return nil
local data = vim.env.XDG_DATA_HOME
if not (data and #data > 0) then
data = (vim.env.HOME or "") .. "/.local/share"
end
return (data:gsub("/+$", "")) .. "/heph/hephd.sock"
end
--- Apply the default keymaps (no-op when `opts.keymaps` is false).