From 5991670ef281114d18b6f9f60968e17b6254e9d4 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 3 Oct 2025 09:34:25 -0400 Subject: [PATCH] fix health and hl groups --- doc/cp.nvim.txt | 14 ++++++++------ lua/cp/health.lua | 15 +++++++++++---- lua/cp/runner/execute.lua | 2 +- lua/cp/runner/run_render.lua | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/cp.nvim.txt b/doc/cp.nvim.txt index 95ace6f..56802bf 100644 --- a/doc/cp.nvim.txt +++ b/doc/cp.nvim.txt @@ -419,11 +419,12 @@ Status Indicators ~ Test cases use competitive programming terminology with color highlighting: - AC Accepted (passed) - Green - WA Wrong Answer (output mismatch) - Red - TLE Time Limit Exceeded (timeout) - Orange - MLE Memory Limit Exceeded Error (heuristic) - Orange - RTE Runtime Error (other non-zero exit code) - Purple + AC Accepted (passed) + WA Wrong Answer (output mismatch) + TLE Time Limit Exceeded (timeout) + MLE Memory Limit Exceeded Error (heuristic) + RTE Runtime Error (other non-zero exit code) + NA Any other state (undecipherable, error, running) < ============================================================================== @@ -442,8 +443,9 @@ Test cases use competitive programming terminology with color highlighting: CpTestAC Green foreground for AC status CpTestWA Red foreground for WA status CpTestTLE Orange foreground for TLE status + CpTestMLE Orange foreground for MLE status CpTestRTE Purple foreground for RTE status - CpTestPending Gray foreground for pending tests + CpTestNA Gray foreground for remaining state ANSI Color Groups ~ diff --git a/lua/cp/health.lua b/lua/cp/health.lua index 7b5ba37..c5e5113 100644 --- a/lua/cp/health.lua +++ b/lua/cp/health.lua @@ -34,11 +34,18 @@ local function check_required() vim.health.info('Python virtual environment not set up (created on first scrape)') end - local cap = utils.time_capability() - if cap.ok then - vim.health.ok('GNU time found: ' .. cap.path) + local time_cap = utils.time_capability() + if time_cap.ok then + vim.health.ok('GNU time found: ' .. time_cap.path) else - vim.health.error('GNU time not found: ' .. (cap.reason or '')) + vim.health.error('GNU time not found: ' .. (time_cap.reason or '')) + end + + local timeout_cap = utils.time_capability() + if timeout_cap.ok then + vim.health.ok('GNU timeout found: ' .. timeout_cap.path) + else + vim.health.error('GNU timeout not found: ' .. (timeout_cap.reason or '')) end end diff --git a/lua/cp/runner/execute.lua b/lua/cp/runner/execute.lua index 09cf062..4ad0f3b 100644 --- a/lua/cp/runner/execute.lua +++ b/lua/cp/runner/execute.lua @@ -93,7 +93,7 @@ local function parse_and_strip_time_v(output) for line in tail:gmatch('[^\n]+') do local kb = line:match('Maximum resident set size %(kbytes%):%s*(%d+)') if kb then - peak_kb = tonumber(kb) + peak_kb = tonumber(kb) or 0 end end diff --git a/lua/cp/runner/run_render.lua b/lua/cp/runner/run_render.lua index 3ac6d5f..027aae3 100644 --- a/lua/cp/runner/run_render.lua +++ b/lua/cp/runner/run_render.lua @@ -40,7 +40,7 @@ function M.get_status_info(ran_test_case) return { text = 'WA', highlight_group = 'CpTestWA' } end - return { text = 'N/A', highlight_group = 'CpTestPending' } + return { text = 'N/A', highlight_group = 'CpTestNA' } end local function format_exit_code(code) @@ -354,7 +354,7 @@ function M.get_highlight_groups() CpTestTLE = { fg = '#f59e0b' }, CpTestMLE = { fg = '#f59e0b' }, CpTestRTE = { fg = '#8b5cf6' }, - CpTestPending = { fg = '#6b7280' }, + CpTestNA = { fg = '#6b7280' }, CpDiffRemoved = { fg = '#ef4444', bg = '#1f1f1f' }, CpDiffAdded = { fg = '#10b981', bg = '#1f1f1f' }, }