preview.nvim/lua
Barrett Ruth e59b5eb241
refactor(compiler): replace 7 state tables with unified BufState
Problem: `compiler.lua` tracked per-buffer state across 7 separate
module-level tables, causing scattered cleanup, triplicated
error-handling blocks, accumulating `BufUnload` autocmds on every
compile, and a race condition where `active[bufnr]` (cleared
asynchronously on process exit) was used as the toggle on/off gate.

Solution: Consolidate all per-buffer state into a single `state` table
holding a `preview.BufState` record per buffer. Extract `handle_errors`
and `clear_errors` helpers. Move `BufUnload` lifecycle entirely into
`M.toggle` with `unload_autocmd` tracking to prevent accumulation.
Toggle now gates on `s.watching` (synchronous boolean) and reopens a
closed viewer when watching is active rather than stopping.
2026-03-05 23:54:07 -05:00
..
preview refactor(compiler): replace 7 state tables with unified BufState 2026-03-05 23:54:07 -05:00