From 0b5c0f0c405dd009def4b6de8e430af38aaeb8e8 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 27 Jan 2026 18:04:56 -0500 Subject: [PATCH 01/15] fix(ci): only run luarocks build on successful ci --- .github/workflows/ci.yaml | 111 ++++++++++++++++++++++++++++++++ .github/workflows/luarocks.yaml | 21 +++--- 2 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..fea1ba2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,111 @@ +name: ci +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + changes: + runs-on: ubuntu-latest + outputs: + lua: ${{ steps.changes.outputs.lua }} + python: ${{ steps.changes.outputs.python }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + lua: + - 'lua/**' + - 'spec/**' + - 'plugin/**' + - 'after/**' + - 'ftdetect/**' + - '*.lua' + - '.luarc.json' + - 'stylua.toml' + - 'selene.toml' + python: + - 'scripts/**' + - 'scrapers/**' + - 'tests/**' + - 'pyproject.toml' + - 'uv.lock' + + lua-format: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.lua == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: 2.1.0 + args: --check . + + lua-lint: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.lua == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: NTBBloodbath/selene-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --display-style quiet . + + lua-typecheck: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.lua == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: mrcjkb/lua-typecheck-action@v0 + with: + checklevel: Warning + directories: lua + configpath: .luarc.json + + python-format: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv tool install ruff + - run: ruff format --check . + + python-lint: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv tool install ruff + - run: ruff check . + + python-typecheck: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv sync --dev + - run: uvx ty check . + + python-test: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + - run: uv sync --dev + - run: uv run camoufox fetch + - run: uv run pytest tests/ -v diff --git a/.github/workflows/luarocks.yaml b/.github/workflows/luarocks.yaml index c64568f..b9bf08f 100644 --- a/.github/workflows/luarocks.yaml +++ b/.github/workflows/luarocks.yaml @@ -1,18 +1,17 @@ -name: Release - +name: luarocks on: - push: - tags: - - '*' - workflow_dispatch: - + workflow_run: + workflows: ["ci"] + types: + - completed jobs: - publish-luarocks: - name: Publish to LuaRocks + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Publish to LuaRocks - uses: nvim-neorocks/luarocks-tag-release@v7 + with: + ref: ${{ github.event.workflow_run.head_sha }} + - uses: nvim-neorocks/luarocks-tag-release@v7 env: LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} From bd25f1db0beea2bc1fd150a046accce10723224b Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 27 Jan 2026 18:09:57 -0500 Subject: [PATCH 02/15] fix(ci): only run on tag push --- .github/workflows/luarocks.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/luarocks.yaml b/.github/workflows/luarocks.yaml index b9bf08f..58af36c 100644 --- a/.github/workflows/luarocks.yaml +++ b/.github/workflows/luarocks.yaml @@ -1,17 +1,21 @@ name: luarocks + on: - workflow_run: - workflows: ["ci"] - types: - - completed + push: + tags: + - "v*" + jobs: + ci: + uses: ./.github/workflows/ci.yml + publish: - if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }} + needs: ci runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.event.workflow_run.head_sha }} + - uses: nvim-neorocks/luarocks-tag-release@v7 env: LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} From 6966e8e101c02159e6ca2c2857b7715dc7ae52fc Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 27 Jan 2026 18:14:54 -0500 Subject: [PATCH 03/15] feat: misc tests --- .github/workflows/luarocks.yaml | 2 +- .github/workflows/quality.yaml | 2 +- .github/workflows/test.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/luarocks.yaml b/.github/workflows/luarocks.yaml index 58af36c..95eaf0f 100644 --- a/.github/workflows/luarocks.yaml +++ b/.github/workflows/luarocks.yaml @@ -7,7 +7,7 @@ on: jobs: ci: - uses: ./.github/workflows/ci.yml + uses: ./.github/workflows/ci.yaml publish: needs: ci diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index f6f27bc..731e74b 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -1,4 +1,4 @@ -name: Code Quality +name: quality on: pull_request: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4c1cc1f..ed7be0c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: Tests +name: tests on: pull_request: From de1295d361dbadc9f5089e7c1879bf11ac0540f1 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 27 Jan 2026 18:19:49 -0500 Subject: [PATCH 04/15] fix ci --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fea1ba2..bf6bcea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,6 @@ name: ci on: + workflow_call: pull_request: branches: [main] push: From c06d81959702fc6616dfda678346c2429c13993a Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 1 Feb 2026 17:01:29 -0500 Subject: [PATCH 05/15] fix(ci): fix rockspec url --- cp.nvim-scm-1.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cp.nvim-scm-1.rockspec b/cp.nvim-scm-1.rockspec index e38d924..8152b7b 100644 --- a/cp.nvim-scm-1.rockspec +++ b/cp.nvim-scm-1.rockspec @@ -2,7 +2,7 @@ rockspec_format = '3.0' package = 'cp.nvim' version = 'scm-1' -source = { url = 'git://github.com/barrett-ruth/cp.nvim' } +source = { url = 'git://github.com/barrettruth/cp.nvim' } build = { type = 'builtin' } test_dependencies = { From 5cd6f75419466e4a10e0c4aaa18593fb49ddfebb Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 1 Feb 2026 17:11:51 -0500 Subject: [PATCH 06/15] fix username too --- doc/cp.nvim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cp.nvim.txt b/doc/cp.nvim.txt index 866346f..1371ef5 100644 --- a/doc/cp.nvim.txt +++ b/doc/cp.nvim.txt @@ -208,7 +208,7 @@ CONFIGURATION *cp-config* Here's an example configuration with lazy.nvim: >lua { - 'barrett-ruth/cp.nvim', + 'barrettruth/cp.nvim', cmd = 'CP', build = 'uv sync', opts = { From c8f735617a4696d7cf024cb96b1e293568155828 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 2 Feb 2026 13:13:08 -0500 Subject: [PATCH 07/15] misc bugfixes --- lua/cp/runner/execute.lua | 2 ++ lua/cp/scraper.lua | 2 +- lua/cp/ui/views.lua | 31 +++++++++++++++++++++++++++++++ lua/cp/utils.lua | 4 ++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lua/cp/runner/execute.lua b/lua/cp/runner/execute.lua index 5c89c8a..76d055a 100644 --- a/lua/cp/runner/execute.lua +++ b/lua/cp/runner/execute.lua @@ -194,6 +194,8 @@ function M.compile_problem(debug, on_complete) return end + require('cp.utils').ensure_dirs() + local binary = debug and state.get_debug_file() or state.get_binary_file() local substitutions = { source = state.get_source_file(), binary = binary } diff --git a/lua/cp/scraper.lua b/lua/cp/scraper.lua index 3c0af30..c42d8be 100644 --- a/lua/cp/scraper.lua +++ b/lua/cp/scraper.lua @@ -186,7 +186,7 @@ function M.scrape_all_tests(platform, contest_id, callback) return end vim.schedule(function() - vim.system({ 'mkdir', '-p', 'build', 'io' }):wait() + require('cp.utils').ensure_dirs() local config = require('cp.config') local base_name = config.default_filename(contest_id, ev.problem_id) for i, t in ipairs(ev.tests) do diff --git a/lua/cp/ui/views.lua b/lua/cp/ui/views.lua index 4b03b68..c1d25fc 100644 --- a/lua/cp/ui/views.lua +++ b/lua/cp/ui/views.lua @@ -13,6 +13,7 @@ local utils = require('cp.utils') local current_diff_layout = nil local current_mode = nil +local io_view_running = false function M.disable() local active_panel = state.get_active_panel() @@ -390,6 +391,8 @@ function M.ensure_io_view() return end + require('cp.utils').ensure_dirs() + local source_file = state.get_source_file() if source_file then local source_file_abs = vim.fn.fnamemodify(source_file, ':p') @@ -622,6 +625,12 @@ local function render_io_view_results(io_state, test_indices, mode, combined_res end function M.run_io_view(test_indices_arg, debug, mode) + if io_view_running then + logger.log('Tests already running', vim.log.levels.WARN) + return + end + io_view_running = true + logger.log(('%s tests...'):format(debug and 'Debugging' or 'Running'), vim.log.levels.INFO, true) mode = mode or 'combined' @@ -633,6 +642,7 @@ function M.run_io_view(test_indices_arg, debug, mode) 'No platform/contest/problem configured. Use :CP [...] first.', vim.log.levels.ERROR ) + io_view_running = false return end @@ -640,6 +650,7 @@ function M.run_io_view(test_indices_arg, debug, mode) local contest_data = cache.get_contest_data(platform, contest_id) if not contest_data or not contest_data.index_map then logger.log('No test cases available.', vim.log.levels.ERROR) + io_view_running = false return end @@ -656,11 +667,13 @@ function M.run_io_view(test_indices_arg, debug, mode) local combined = cache.get_combined_test(platform, contest_id, problem_id) if not combined then logger.log('No combined test available', vim.log.levels.ERROR) + io_view_running = false return end else if not run.load_test_cases() then logger.log('No test cases available', vim.log.levels.ERROR) + io_view_running = false return end end @@ -681,6 +694,7 @@ function M.run_io_view(test_indices_arg, debug, mode) ), vim.log.levels.WARN ) + io_view_running = false return end end @@ -698,6 +712,7 @@ function M.run_io_view(test_indices_arg, debug, mode) local io_state = state.get_io_view_state() if not io_state then + io_view_running = false return end @@ -711,6 +726,7 @@ function M.run_io_view(test_indices_arg, debug, mode) execute.compile_problem(debug, function(compile_result) if not vim.api.nvim_buf_is_valid(io_state.output_buf) then + io_view_running = false return end @@ -730,6 +746,7 @@ function M.run_io_view(test_indices_arg, debug, mode) local ns = vim.api.nvim_create_namespace('cp_io_view_compile_error') utils.update_buffer_content(io_state.output_buf, lines, highlights, ns) + io_view_running = false return end @@ -737,6 +754,7 @@ function M.run_io_view(test_indices_arg, debug, mode) local combined = cache.get_combined_test(platform, contest_id, problem_id) if not combined then logger.log('No combined test found', vim.log.levels.ERROR) + io_view_running = false return end @@ -745,18 +763,21 @@ function M.run_io_view(test_indices_arg, debug, mode) run.run_combined_test(debug, function(result) if not result then logger.log('Failed to run combined test', vim.log.levels.ERROR) + io_view_running = false return end if vim.api.nvim_buf_is_valid(io_state.output_buf) then render_io_view_results(io_state, test_indices, mode, result, combined.input) end + io_view_running = false end) else run.run_all_test_cases(test_indices, debug, nil, function() if vim.api.nvim_buf_is_valid(io_state.output_buf) then render_io_view_results(io_state, test_indices, mode, nil, nil) end + io_view_running = false end) end end) @@ -859,6 +880,9 @@ function M.toggle_panel(panel_opts) end local function refresh_panel() + if state.get_active_panel() ~= 'run' then + return + end if not test_buffers.tab_buf or not vim.api.nvim_buf_is_valid(test_buffers.tab_buf) then return end @@ -884,6 +908,10 @@ function M.toggle_panel(panel_opts) vim.cmd.normal({ 'zz', bang = true }) end) end + + if test_windows.tab_win and vim.api.nvim_win_is_valid(test_windows.tab_win) then + vim.api.nvim_set_current_win(test_windows.tab_win) + end end local function navigate_test_case(delta) @@ -942,6 +970,9 @@ function M.toggle_panel(panel_opts) local function finalize_panel() vim.schedule(function() + if state.get_active_panel() ~= 'run' then + return + end if config.ui.ansi then require('cp.ui.ansi').setup_highlight_groups() end diff --git a/lua/cp/utils.lua b/lua/cp/utils.lua index c2f353a..654c2ef 100644 --- a/lua/cp/utils.lua +++ b/lua/cp/utils.lua @@ -262,4 +262,8 @@ function M.cwd_executables() return out end +function M.ensure_dirs() + vim.system({ 'mkdir', '-p', 'build', 'io' }):wait() +end + return M From f184a7874ae353d545367ac24076fd6cd3359900 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 01:38:13 -0500 Subject: [PATCH 08/15] feat: update docs --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 7d439f9..cc17d80 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,15 @@ https://github.com/user-attachments/assets/e81d8dfb-578f-4a79-9989-210164fc0148 - **Language agnostic**: Works with any language - **Diff viewer**: Compare expected vs actual output with 3 diff modes +## Installation + +Install using your package manager of choice or with +[luarocks](https://luarocks.org/modules/barrettruth/cp.nvim): + +``` +luarocks install cp.nvim +``` + ## Optional Dependencies - [uv](https://docs.astral.sh/uv/) for problem scraping From f9f993db0cbbe01ca63e79f290ec990e360d3438 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 01:39:26 -0500 Subject: [PATCH 09/15] fix: pre-commit syntax error --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22e6d2e..410cfc2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: hooks: - id: prettier name: prettier - files: \.(md|,toml,yaml,sh)$ + files: \.(md,toml,yaml,sh)$ - repo: local hooks: From 01efc7c3441b7219909adb580c77a5531d2b29dc Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 01:41:35 -0500 Subject: [PATCH 10/15] fix(ci): prettier format --- .github/workflows/luarocks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/luarocks.yaml b/.github/workflows/luarocks.yaml index 95eaf0f..5be8b55 100644 --- a/.github/workflows/luarocks.yaml +++ b/.github/workflows/luarocks.yaml @@ -3,7 +3,7 @@ name: luarocks on: push: tags: - - "v*" + - 'v*' jobs: ci: From 08fb654d2341de8259e8e5c74ad8e636322b47d7 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 01:43:13 -0500 Subject: [PATCH 11/15] format yml too in pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 410cfc2..971ffbe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: hooks: - id: prettier name: prettier - files: \.(md,toml,yaml,sh)$ + files: \.(md|toml|ya?ml|sh)$ - repo: local hooks: From 11b8365aacdc59befe4c35bca97b35ac1aa96a6e Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 01:49:47 -0500 Subject: [PATCH 12/15] via, not main --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc17d80..cf82417 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ https://github.com/user-attachments/assets/e81d8dfb-578f-4a79-9989-210164fc0148 ## Installation -Install using your package manager of choice or with +Install using your package manager of choice or via [luarocks](https://luarocks.org/modules/barrettruth/cp.nvim): ``` From 1a7e9517baea7492db90c8b782efeb9479508ea1 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 01:50:22 -0500 Subject: [PATCH 13/15] force --- new | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 new diff --git a/new b/new new file mode 100644 index 0000000..e69de29 From ec487aa489dfdf330cb08b6b5f696fd62b1b02c9 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 16:12:47 -0500 Subject: [PATCH 14/15] feat: config update to viom.g --- doc/cp.nvim.txt | 115 +++++++++++++++++++++++------------------------- lua/cp/init.lua | 22 ++++----- 2 files changed, 66 insertions(+), 71 deletions(-) diff --git a/doc/cp.nvim.txt b/doc/cp.nvim.txt index 1371ef5..d6d1d73 100644 --- a/doc/cp.nvim.txt +++ b/doc/cp.nvim.txt @@ -205,71 +205,66 @@ Debug Builds ~ ============================================================================== CONFIGURATION *cp-config* -Here's an example configuration with lazy.nvim: +Configuration is done via `vim.g.cp_config`. Set this before using the plugin: >lua - { - 'barrettruth/cp.nvim', - cmd = 'CP', - build = 'uv sync', - opts = { - languages = { - cpp = { - extension = 'cc', - commands = { - build = { 'g++', '-std=c++17', '{source}', '-o', '{binary}', - '-fdiagnostics-color=always' }, - run = { '{binary}' }, - debug = { 'g++', '-std=c++17', '-fsanitize=address,undefined', - '{source}', '-o', '{binary}' }, - }, - }, - python = { - extension = 'py', - commands = { - run = { 'python', '{source}' }, - debug = { 'python', '{source}' }, - }, + vim.g.cp_config = { + languages = { + cpp = { + extension = 'cc', + commands = { + build = { 'g++', '-std=c++17', '{source}', '-o', '{binary}', + '-fdiagnostics-color=always' }, + run = { '{binary}' }, + debug = { 'g++', '-std=c++17', '-fsanitize=address,undefined', + '{source}', '-o', '{binary}' }, }, }, - platforms = { - cses = { - enabled_languages = { 'cpp', 'python' }, - default_language = 'cpp', - overrides = { - cpp = { extension = 'cpp', commands = { build = { ... } } } - }, - }, - atcoder = { - enabled_languages = { 'cpp', 'python' }, - default_language = 'cpp', - }, - codeforces = { - enabled_languages = { 'cpp', 'python' }, - default_language = 'cpp', + python = { + extension = 'py', + commands = { + run = { 'python', '{source}' }, + debug = { 'python', '{source}' }, }, }, - open_url = true, - debug = false, - ui = { - ansi = true, - run = { - width = 0.3, - next_test_key = '', -- or nil to disable - prev_test_key = '', -- or nil to disable + }, + platforms = { + cses = { + enabled_languages = { 'cpp', 'python' }, + default_language = 'cpp', + overrides = { + cpp = { extension = 'cpp', commands = { build = { ... } } } }, - panel = { - diff_modes = { 'side-by-side', 'git', 'vim' }, - max_output_lines = 50, - }, - diff = { - git = { - args = { 'diff', '--no-index', '--word-diff=plain', - '--word-diff-regex=.', '--no-prefix' }, - }, - }, - picker = 'telescope', }, - } + atcoder = { + enabled_languages = { 'cpp', 'python' }, + default_language = 'cpp', + }, + codeforces = { + enabled_languages = { 'cpp', 'python' }, + default_language = 'cpp', + }, + }, + open_url = true, + debug = false, + ui = { + ansi = true, + run = { + width = 0.3, + next_test_key = '', -- or nil to disable + prev_test_key = '', -- or nil to disable + }, + panel = { + diff_modes = { 'side-by-side', 'git', 'vim' }, + max_output_lines = 50, + }, + diff = { + git = { + args = { 'diff', '--no-index', '--word-diff=plain', + '--word-diff-regex=.', '--no-prefix' }, + }, + }, + picker = 'telescope', + }, } < @@ -279,7 +274,7 @@ the default; per-platform overrides can tweak 'extension' or 'commands'. For example, to run CodeForces contests with Python by default: >lua - { + vim.g.cp_config = { platforms = { codeforces = { default_language = 'python', @@ -290,7 +285,7 @@ For example, to run CodeForces contests with Python by default: Any language is supported provided the proper configuration. For example, to run CSES problems with Rust using the single schema: >lua - { + vim.g.cp_config = { languages = { rust = { extension = 'rs', diff --git a/lua/cp/init.lua b/lua/cp/init.lua index 64a997d..fac3044 100644 --- a/lua/cp/init.lua +++ b/lua/cp/init.lua @@ -11,25 +11,25 @@ if vim.fn.has('nvim-0.10.0') == 0 then return {} end -local user_config = {} -local config = nil local initialized = false +local function ensure_initialized() + if initialized then + return + end + local user_config = vim.g.cp_config or {} + local config = config_module.setup(user_config) + config_module.set_current_config(config) + initialized = true +end + ---@return nil function M.handle_command(opts) + ensure_initialized() local commands = require('cp.commands') commands.handle_command(opts) end -function M.setup(opts) - opts = opts or {} - user_config = opts - config = config_module.setup(user_config) - config_module.set_current_config(config) - - initialized = true -end - function M.is_initialized() return initialized end From dc635d5167e465df06e8ffe0212e4ff029541b35 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Feb 2026 21:07:01 -0500 Subject: [PATCH 15/15] chore: add issue templates --- .github/ISSUE_TEMPLATE/bug_report.yaml | 78 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yaml | 5 ++ .github/ISSUE_TEMPLATE/feature_request.yaml | 30 ++++++++ 3 files changed, 113 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yaml create mode 100644 .github/ISSUE_TEMPLATE/config.yaml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..5742799 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,78 @@ +name: Bug Report +description: Report a bug +title: 'bug: ' +labels: [bug] +body: + - type: checkboxes + attributes: + label: Prerequisites + options: + - label: + I have searched [existing + issues](https://github.com/barrettruth/cp.nvim/issues) + required: true + - label: I have updated to the latest version + required: true + + - type: textarea + attributes: + label: 'Neovim version' + description: 'Output of `nvim --version`' + render: text + validations: + required: true + + - type: input + attributes: + label: 'Operating system' + placeholder: 'e.g. Arch Linux, macOS 15, Ubuntu 24.04' + validations: + required: true + + - type: textarea + attributes: + label: Description + description: What happened? What did you expect? + validations: + required: true + + - type: textarea + attributes: + label: Steps to reproduce + description: Minimal steps to trigger the bug + value: | + 1. + 2. + 3. + validations: + required: true + + - type: textarea + attributes: + label: 'Health check' + description: 'Output of `:checkhealth cp`' + render: text + + - type: textarea + attributes: + label: Minimal reproduction + description: | + Save the script below as `repro.lua`, edit if needed, and run: + ``` + nvim -u repro.lua + ``` + Confirm the bug reproduces with this config before submitting. + render: lua + value: | + vim.env.LAZY_STDPATH = '.repro' + load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))() + require('lazy.nvim').setup({ + spec = { + { + 'barrett-ruth/cp.nvim', + opts = {}, + }, + }, + }) + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 0000000..12ef1b0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Questions + url: https://github.com/barrettruth/cp.nvim/discussions + about: Ask questions and discuss ideas diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..39c6692 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,30 @@ +name: Feature Request +description: Suggest a feature +title: 'feat: ' +labels: [enhancement] +body: + - type: checkboxes + attributes: + label: Prerequisites + options: + - label: + I have searched [existing + issues](https://github.com/barrettruth/cp.nvim/issues) + required: true + + - type: textarea + attributes: + label: Problem + description: What problem does this solve? + validations: + required: true + + - type: textarea + attributes: + label: Proposed solution + validations: + required: true + + - type: textarea + attributes: + label: Alternatives considered