From d85ce3362fca2ced4d9367b83128ce41c3a9b2dc Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Wed, 3 Jun 2026 11:55:07 -0700 Subject: [PATCH] infra(nvim): add stylua formatter + prek hook; normalize heph.nvim Lua A `.stylua.toml` (Spaces/2, else stylua defaults) + a `stylua-system` prek hook make Lua whitespace formatter-enforced (the repo had no Lua formatter, so style was hand-maintained and drifted). Normalized the three non-conformant files in passing. 21 nvim e2e specs still green. Co-Authored-By: Claude Opus 4.8 (1M context) --- .stylua.toml | 5 +++++ docs/changelog.d/v1-prototype.infra.md | 1 + heph.nvim/lua/heph/init.lua | 5 +---- heph.nvim/tests/e2e/capture_spec.lua | 5 +---- heph.nvim/tests/e2e/helpers.lua | 20 +++++++++++--------- prek.toml | 7 +++++++ 6 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 .stylua.toml diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..9482c7c --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,5 @@ +# Opinionated Lua formatting for heph.nvim, enforced via prek's stylua hook. +# Spaces/2 matches the existing plugin style; everything else is stylua's +# defaults (the formatter is the source of truth — don't hand-format). +indent_type = "Spaces" +indent_width = 2 diff --git a/docs/changelog.d/v1-prototype.infra.md b/docs/changelog.d/v1-prototype.infra.md index 7392070..33f276c 100644 --- a/docs/changelog.d/v1-prototype.infra.md +++ b/docs/changelog.d/v1-prototype.infra.md @@ -1 +1,2 @@ +- Lua is now formatted by **stylua** (a `.stylua.toml` + a `stylua-system` prek hook), so heph.nvim's whitespace is enforced by an opinionated formatter rather than by hand. - `mise run import-todoist` — a one-way importer that seeds a heph store from your Todoist projects + active tasks (project hierarchy, priority→attention, do-dates, natural-language recurrence, descriptions + sub-tasks as context items). Dry-run by default; `-- --commit` writes into your real store after backing it up. See [[import-todoist]]. diff --git a/heph.nvim/lua/heph/init.lua b/heph.nvim/lua/heph/init.lua index c29e605..dd12fdc 100644 --- a/heph.nvim/lua/heph/init.lua +++ b/heph.nvim/lua/heph/init.lua @@ -30,10 +30,7 @@ function M.setup(opts) 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 - ) + require("heph.util").notify("no hephd at " .. cfg.socket .. " — run `heph daemon start`", vim.log.levels.WARN) end config.apply_keymaps(cfg) diff --git a/heph.nvim/tests/e2e/capture_spec.lua b/heph.nvim/tests/e2e/capture_spec.lua index f4891a7..9a2b8f4 100644 --- a/heph.nvim/tests/e2e/capture_spec.lua +++ b/heph.nvim/tests/e2e/capture_spec.lua @@ -34,10 +34,7 @@ describe("task capture to done", function() vim.api.nvim_win_set_cursor(0, { 2, 0 }) require("heph.view").open_under_cursor() local ctxbuf = vim.api.nvim_get_current_buf() - assert.are.equal( - "heph://node/" .. ranked[1].canonical_context_id, - vim.api.nvim_buf_get_name(ctxbuf) - ) + assert.are.equal("heph://node/" .. ranked[1].canonical_context_id, vim.api.nvim_buf_get_name(ctxbuf)) -- Add a checklist item and save. vim.api.nvim_buf_set_lines(ctxbuf, 0, -1, false, { "- [ ] buy shingles" }) diff --git a/heph.nvim/tests/e2e/helpers.lua b/heph.nvim/tests/e2e/helpers.lua index f69c2be..a3d8ceb 100644 --- a/heph.nvim/tests/e2e/helpers.lua +++ b/heph.nvim/tests/e2e/helpers.lua @@ -79,11 +79,16 @@ end --- tests of the no-daemon-running case). `rm` removes it. function M.tmp() local dir = unique_dir() - return { dir = dir, sock = dir .. "/s", db = dir .. "/db", rm = function() - pcall(function() - vim.fn.delete(dir, "rf") - end) - end } + return { + dir = dir, + sock = dir .. "/s", + db = dir .. "/db", + rm = function() + pcall(function() + vim.fn.delete(dir, "rf") + end) + end, + } end --- Start a daemon on explicit paths and bind the plugin's rpc to it. Returns a @@ -91,10 +96,7 @@ end function M.start_on(dir, sock, db) assert(#sock < 104, "socket path too long for sun_path: " .. sock) local bin = M.hephd_bin() - assert( - vim.fn.executable(bin) == 1, - "hephd not built/executable: " .. bin .. " (run: cargo build -p hephd)" - ) + assert(vim.fn.executable(bin) == 1, "hephd not built/executable: " .. bin .. " (run: cargo build -p hephd)") local exited = { done = false } local d = spawn({ diff --git a/prek.toml b/prek.toml index caa02e1..7de95ab 100644 --- a/prek.toml +++ b/prek.toml @@ -76,6 +76,13 @@ repo = "https://github.com/rbubley/mirrors-prettier" rev = "v3.8.1" hooks = [{ id = "prettier", types_or = ["json"], args = ["--tab-width", "2"] }] +# Lua formatting (heph.nvim) - stylua, configured by .stylua.toml. Uses the +# system binary (installed locally; CI runs Rust/nvim suites via Dagger, not prek). +[[repos]] +repo = "https://github.com/JohnnyMorganz/StyLua" +rev = "v2.4.1" +hooks = [{ id = "stylua-system" }] + # GitHub/Forgejo Actions workflow linting [[repos]] repo = "https://github.com/rhysd/actionlint"