refactor(logger): table-based LogOpts; add sync, on_done to test stream

Problem: `logger.log` positional args were hard to extend, and adding
`sync` support for pre-block notifications required a clean API. Test
stream completion had no user-visible signal. `setup_contest` could
silently overwrite files when a user's `filename` config returned
colliding paths.

Solution: Replace `(msg, level, override)` with `(msg, LogOpts?)` where
`LogOpts` carries `level`, `override`, and `sync`. Sync path calls
`vim.notify` directly; async path uses `vim.schedule` as before. Add
`on_done` callback to `scrape_all_tests`, fired via `on_exit` and
surfaced as a "Loaded N tests." notification. Detect filename collisions
in `proceed()` before touching the filesystem. Migrate all call sites.
This commit is contained in:
Barrett Ruth 2026-03-05 12:54:37 -05:00
parent 127089c57f
commit 29af2df858
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
18 changed files with 126 additions and 117 deletions

View file

@ -152,7 +152,7 @@ local function discover_nix_submit_cmd()
:wait()
if result.code ~= 0 then
logger.log('nix build #submitEnv failed: ' .. (result.stderr or ''), vim.log.levels.WARN)
logger.log('nix build #submitEnv failed: ' .. (result.stderr or ''), { level = vim.log.levels.WARN })
return false
end
@ -160,7 +160,7 @@ local function discover_nix_submit_cmd()
local submit_cmd = store_path .. '/bin/cp-nvim-submit'
if vim.fn.executable(submit_cmd) ~= 1 then
logger.log('nix submit cmd not executable at ' .. submit_cmd, vim.log.levels.WARN)
logger.log('nix submit cmd not executable at ' .. submit_cmd, { level = vim.log.levels.WARN })
return false
end
@ -216,7 +216,7 @@ local function discover_nix_python()
:wait()
if result.code ~= 0 then
logger.log('nix build #pythonEnv failed: ' .. (result.stderr or ''), vim.log.levels.WARN)
logger.log('nix build #pythonEnv failed: ' .. (result.stderr or ''), { level = vim.log.levels.WARN })
return false
end
@ -224,7 +224,7 @@ local function discover_nix_python()
local python_path = store_path .. '/bin/python3'
if vim.fn.executable(python_path) ~= 1 then
logger.log('nix python not executable at ' .. python_path, vim.log.levels.WARN)
logger.log('nix python not executable at ' .. python_path, { level = vim.log.levels.WARN })
return false
end
@ -270,7 +270,7 @@ function M.setup_python_env()
if result.code ~= 0 then
logger.log(
'Failed to setup Python environment: ' .. (result.stderr or ''),
vim.log.levels.ERROR
{ level = vim.log.levels.ERROR }
)
return false
end
@ -292,7 +292,7 @@ function M.setup_python_env()
logger.log(
'No Python environment available. Install uv (https://docs.astral.sh/uv/) or use nix.',
vim.log.levels.WARN
{ level = vim.log.levels.WARN }
)
return false
end