fix(ci): fix the format

This commit is contained in:
Barrett Ruth 2025-09-19 23:41:23 -04:00
parent cdcf11767e
commit 97873ffd37
4 changed files with 95 additions and 72 deletions

View file

@ -1,9 +1,10 @@
*cp.txt* Competitive programming plugin for Neovim *cp.txt* Competitive programming plugin for Neovim *cp.txt*
Author: Barrett Ruth <br.barrettruth@gmail.com> Author: Barrett Ruth <br.barrettruth@gmail.com>
License: Same terms as Vim itself (see |license|) License: Same terms as Vim itself (see |license|)
INTRODUCTION *cp* *cp.nvim* ==============================================================================
INTRODUCTION *cp* *cp.nvim*
cp.nvim is a competitive programming plugin that automates problem setup, cp.nvim is a competitive programming plugin that automates problem setup,
compilation, and testing workflow for online judges. compilation, and testing workflow for online judges.
@ -11,7 +12,8 @@ compilation, and testing workflow for online judges.
Supported platforms: AtCoder, Codeforces, CSES Supported platforms: AtCoder, Codeforces, CSES
Supported languages: C++, Python Supported languages: C++, Python
REQUIREMENTS *cp-requirements* ==============================================================================
REQUIREMENTS *cp-requirements*
- Neovim 0.10.0+ - Neovim 0.10.0+
- uv package manager (https://docs.astral.sh/uv/) - uv package manager (https://docs.astral.sh/uv/)
@ -20,99 +22,106 @@ REQUIREMENTS *cp-requirements*
Optional: Optional:
- LuaSnip for template expansion (https://github.com/L3MON4D3/LuaSnip) - LuaSnip for template expansion (https://github.com/L3MON4D3/LuaSnip)
COMMANDS *cp-commands* ==============================================================================
COMMANDS *cp-commands*
*:CP* :CP *:CP*
cp.nvim uses a single :CP command with intelligent argument parsing: cp.nvim uses a single :CP command with intelligent argument parsing:
State Restoration ~ State Restoration ~
:CP Restore contest context from current file.
:CP Restore contest context from current file.
Automatically detects platform, contest, problem, Automatically detects platform, contest, problem,
and language from cached state. Use this after and language from cached state. Use this after
switching files to restore your CP environment. switching files to restore your CP environment.
Requires previous setup with full :CP command. Requires previous setup with full :CP command.
Setup Commands ~ Setup Commands ~
:CP {platform} {contest_id} {problem_id} [--lang={language}]
:CP {platform} {contest_id} {problem_id} [--lang={language}]
Full setup: set platform, load contest metadata, Full setup: set platform, load contest metadata,
and set up specific problem. Scrapes test cases and set up specific problem. Scrapes test cases
and creates source file. and creates source file.
Example: :CP codeforces 1933 a Example: >
Example: :CP codeforces 1933 a --lang=python :CP codeforces 1933 a
:CP codeforces 1933 a --lang=python
:CP {platform} {contest_id} Contest setup: set platform and load contest <
:CP {platform} {contest_id}
Contest setup: set platform and load contest
metadata for navigation. Caches problem list. metadata for navigation. Caches problem list.
Example: :CP atcoder abc324 Example: >
:CP atcoder abc324
:CP {platform} Platform setup: set platform only. <
Example: :CP cses :CP {platform} Platform setup: set platform only.
Example: >
:CP {problem_id} [--lang={language}] :CP cses
<
:CP {problem_id} [--lang={language}]
Problem switch: switch to different problem Problem switch: switch to different problem
within current contest context. within current contest context.
Example: :CP b (switch to problem b) Example: >
Example: :CP b --lang=python :CP b
:CP b --lang=python
Action Commands ~ <
Action Commands ~
:CP run [--debug] Toggle run panel for individual test case :CP run [--debug] Toggle run panel for individual test case
debugging. Shows per-test results with redesigned debugging. Shows per-test results with redesigned
layout for efficient comparison. layout for efficient comparison.
Use --debug flag to compile with debug flags Use --debug flag to compile with debug flags.
Requires contest setup first. Requires contest setup first.
Navigation Commands ~ Navigation Commands ~
:CP next Navigate to next problem in current contest.
:CP next Navigate to next problem in current contest.
Stops at last problem (no wrapping). Stops at last problem (no wrapping).
:CP prev Navigate to previous problem in current contest. :CP prev Navigate to previous problem in current contest.
Stops at first problem (no wrapping). Stops at first problem (no wrapping).
CONFIGURATION *cp-config* ==============================================================================
CONFIGURATION *cp-config*
cp.nvim works out of the box. No setup required. cp.nvim works out of the box. No setup required.
Here's an example configuration with lazy.nvim: > Here's an example configuration with lazy.nvim: >lua
{ {
'barrett-ruth/cp.nvim', 'barrett-ruth/cp.nvim',
cmd = 'CP', cmd = 'CP',
opts = { opts = {
contests = { contests = {
default = { default = {
cpp = { cpp = {
compile = { 'g++', '{source}', '-o', '{binary}', '-std=c++17' }, compile = { 'g++', '{source}', '-o', '{binary}',
test = { '{binary}' }, '-std=c++17' },
debug = { 'g++', '{source}', '-o', '{binary}', '-std=c++17', '-g', '-fsanitize=address,undefined' }, test = { '{binary}' },
}, debug = { 'g++', '{source}', '-o', '{binary}',
python = { '-std=c++17', '-g',
test = { 'python3', '{source}' }, '-fsanitize=address,undefined' },
}, },
python = {
test = { 'python3', '{source}' },
},
},
}, },
}, snippets = {},
snippets = {}, hooks = {
hooks = { before_run = nil,
before_run = nil, before_debug = nil,
before_debug = nil, setup_code = nil,
setup_code = nil, },
}, debug = false,
debug = false, scrapers = { 'atcoder', 'codeforces', 'cses' },
scrapers = { ... }, -- all scrapers enabled by default filename = default_filename, -- <contest id> + <problem id>
filename = default_filename, -- <contest id> + <problem id> run_panel = {
run_panel = { diff_mode = 'vim',
diff_mode = 'vim', next_test_key = '<c-n>',
next_test_key = '<c-n>', prev_test_key = '<c-p>',
prev_test_key = '<c-p>', toggle_diff_key = 't',
toggle_diff_key = 't', max_output_lines = 50,
max_output_lines = 50, },
}, diff = {
diff = { git = {
git = { args = { 'diff', '--no-index', '--word-diff=plain',
args = { 'diff', '--no-index', '--word-diff=plain', '--word-diff-regex=.', '--no-prefix' }, '--word-diff-regex=.', '--no-prefix' },
},
}, },
},
} }
} }
< <

View file

@ -2,13 +2,10 @@ describe('cp.execute', function()
local execute local execute
local mock_system_calls local mock_system_calls
local temp_files local temp_files
local spec_helper = require('spec.spec_helper')
before_each(function() before_each(function()
package.loaded['cp.log'] = { spec_helper.setup()
log = function() end,
set_config = function() end,
}
execute = require('cp.execute') execute = require('cp.execute')
mock_system_calls = {} mock_system_calls = {}
temp_files = {} temp_files = {}
@ -65,7 +62,7 @@ describe('cp.execute', function()
after_each(function() after_each(function()
vim.system = vim.system_original or vim.system vim.system = vim.system_original or vim.system
package.loaded['cp.log'] = nil spec_helper.teardown()
temp_files = {} temp_files = {}
end) end)

View file

@ -3,8 +3,10 @@ describe('cp.scrape', function()
local mock_cache local mock_cache
local mock_system_calls local mock_system_calls
local temp_files local temp_files
local spec_helper = require('spec.spec_helper')
before_each(function() before_each(function()
spec_helper.setup()
temp_files = {} temp_files = {}
mock_cache = { mock_cache = {
@ -85,6 +87,7 @@ describe('cp.scrape', function()
after_each(function() after_each(function()
package.loaded['cp.cache'] = nil package.loaded['cp.cache'] = nil
vim.system = vim.system_original or vim.system vim.system = vim.system_original or vim.system
spec_helper.teardown()
temp_files = {} temp_files = {}
end) end)

14
spec/spec_helper.lua Normal file
View file

@ -0,0 +1,14 @@
local M = {}
function M.setup()
package.loaded['cp.log'] = {
log = function() end,
set_config = function() end,
}
end
function M.teardown()
package.loaded['cp.log'] = nil
end
return M