From 516d1b02b72af0d6e55eaeda55efeeae2dbc2df9 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 20:02:19 -0500 Subject: [PATCH] fix(stress): shorten terminal buffer name and clean up CSES versions Problem: stress terminal buffer showed the full nix python path and absolute script path, making it illegible. CSES language maps included unused version variants. Solution: rename stress terminal buffer to a readable `term://stress.py` format. Use `python` instead of `python3` in `build_run_cmd`. Trim CSES `LANGUAGE_VERSIONS`, `CSES_LANGUAGES`, and `EXTENSIONS` to only the default versions. --- lua/cp/constants.lua | 4 ++-- lua/cp/stress.lua | 3 ++- scrapers/cses.py | 8 +------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lua/cp/constants.lua b/lua/cp/constants.lua index 22a3b76..4515270 100644 --- a/lua/cp/constants.lua +++ b/lua/cp/constants.lua @@ -85,10 +85,10 @@ M.LANGUAGE_VERSIONS = { python = { python3 = '31', pypy3 = '70' }, }, cses = { - cpp = { ['c++11'] = 'C++11', ['c++17'] = 'C++17', ['c++20'] = 'C++20' }, + cpp = { ['c++17'] = 'C++17' }, python = { python3 = 'Python3', pypy3 = 'PyPy3' }, java = { java = 'Java' }, - rust = { rust2018 = 'Rust2018', rust2021 = 'Rust2021' }, + rust = { rust2021 = 'Rust2021' }, }, kattis = { cpp = { ['c++17'] = 'C++', ['c++20'] = 'C++', ['c++23'] = 'C++' }, diff --git a/lua/cp/stress.lua b/lua/cp/stress.lua index f1e60e8..f90008d 100644 --- a/lua/cp/stress.lua +++ b/lua/cp/stress.lua @@ -53,7 +53,7 @@ local function build_run_cmd(file) end return './' .. bin elseif ext == 'py' then - return 'python3 ' .. file + return 'python ' .. file end return './' .. file end @@ -171,6 +171,7 @@ function M.toggle(generator_cmd, brute_cmd) vim.cmd.terminal(cmdline) local term_buf = vim.api.nvim_get_current_buf() + pcall(vim.api.nvim_buf_set_name, term_buf, ("term://stress.py '%s' '%s' '%s'"):format(gen_cmd, brute_run_cmd, binary)) local term_win = vim.api.nvim_get_current_win() local cleaned = false diff --git a/scrapers/cses.py b/scrapers/cses.py index 6beed6b..1ddd292 100644 --- a/scrapers/cses.py +++ b/scrapers/cses.py @@ -31,24 +31,18 @@ HEADERS = { CONNECTIONS = 8 CSES_LANGUAGES: dict[str, dict[str, str]] = { - "C++11": {"name": "C++", "option": "C++11"}, "C++17": {"name": "C++", "option": "C++17"}, - "C++20": {"name": "C++", "option": "C++20"}, "Python3": {"name": "Python3", "option": "CPython3"}, "PyPy3": {"name": "Python3", "option": "PyPy3"}, "Java": {"name": "Java", "option": "Java"}, - "Rust2018": {"name": "Rust", "option": "2018"}, "Rust2021": {"name": "Rust", "option": "2021"}, } EXTENSIONS: dict[str, str] = { - "C++11": "cpp", "C++17": "cpp", - "C++20": "cpp", "Python3": "py", "PyPy3": "py", "Java": "java", - "Rust2018": "rs", "Rust2021": "rs", } @@ -443,7 +437,7 @@ class CSESScraper(BaseScraper): print(json.dumps({"status": "submitting"}), flush=True) ext = EXTENSIONS.get(language_id, "cpp") - lang = CSES_LANGUAGES.get(language_id, {}) + lang = CSES_LANGUAGES.get(language_id, {"name": "C++", "option": "C++17"}) content_b64 = base64.b64encode(source_code.encode()).decode() payload: dict[str, Any] = {