From 57be0c0044cf0babb0e9da622eb317c3326f50e4 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 2 Oct 2025 10:23:01 -0400 Subject: [PATCH] remove keys --- doc/cp.nvim.txt | 8 +++----- lua/cp/commands/cache.lua | 10 ++++++++++ lua/cp/config.lua | 18 ------------------ lua/cp/ui/panel.lua | 4 ++-- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/doc/cp.nvim.txt b/doc/cp.nvim.txt index 1574af7..5e918b7 100644 --- a/doc/cp.nvim.txt +++ b/doc/cp.nvim.txt @@ -83,6 +83,7 @@ COMMANDS *cp-commands* :CP cache read View the cache in a pretty-printed lua buffer. + Exit with q. Command Flags ~ *cp-flags* @@ -153,7 +154,6 @@ Here's an example configuration with lazy.nvim: >lua diff_mode = 'vim', next_test_key = '', prev_test_key = '', - toggle_diff_key = '', max_output_lines = 50, }, diff = { @@ -231,7 +231,6 @@ is required: {next_test_key} (string, default: "") Key to navigate to next test case. {prev_test_key} (string, default: "") Key to navigate to previous test case. {toggle_diff_key} (string, default: "") Key to cycle through diff modes. - {close_key} (string, default: "") Close the run panel/interactive terminal {max_output_lines} (number, default: 50) Maximum lines of test output. *cp.DiffConfig* @@ -535,9 +534,8 @@ RUN PANEL KEYMAPS *cp-test-keys* run_panel.next_test_key) Navigate to previous test case (configurable via run_panel.prev_test_key) - Cycle through diff modes: none → git → vim (configurable - via run_panel.toggle_diff_key) - Exit run panel/interactive terminal and restore layout +t Cycle through diff modes: none → git → vim +q Exit run panel/interactive terminal and restore layout Diff Modes ~ diff --git a/lua/cp/commands/cache.lua b/lua/cp/commands/cache.lua index f3f70e4..8af5ff7 100644 --- a/lua/cp/commands/cache.lua +++ b/lua/cp/commands/cache.lua @@ -21,6 +21,16 @@ function M.handle_cache_command(cmd) vim.api.nvim_buf_set_name(buf, name) vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(data, '\n')) vim.bo[buf].filetype = 'lua' + vim.bo[buf].buftype = 'nofile' + vim.bo[buf].bufhidden = 'wipe' + vim.bo[buf].swapfile = false + vim.api.nvim_buf_set_keymap( + buf, + 'n', + 'q', + 'bd!', + { nowait = true, noremap = true, silent = true } + ) end vim.api.nvim_set_current_buf(buf) diff --git a/lua/cp/config.lua b/lua/cp/config.lua index f59058c..6d96793 100644 --- a/lua/cp/config.lua +++ b/lua/cp/config.lua @@ -33,8 +33,6 @@ ---@field diff_mode "none"|"vim"|"git" Diff backend to use ---@field next_test_key string Key to navigate to next test case ---@field prev_test_key string Key to navigate to previous test case ----@field toggle_diff_key string Key to cycle through diff modes ----@field close_key string Key to close panel/interactive terminal ---@field max_output_lines number Maximum lines of test output to display ---@class DiffGitConfig @@ -104,8 +102,6 @@ M.defaults = { diff_mode = 'none', next_test_key = '', prev_test_key = '', - toggle_diff_key = '', - close_key = '', max_output_lines = 50, }, diff = { @@ -224,20 +220,6 @@ function M.setup(user_config) end, 'prev_test_key must be a non-empty string', }, - toggle_diff_key = { - config.run_panel.toggle_diff_key, - function(value) - return type(value) == 'string' and value ~= '' - end, - 'toggle_diff_key must be a non-empty string', - }, - close_key = { - config.run_panel.close_key, - function(value) - return type(value) == 'string' and value ~= '' - end, - 'close_key must be a non-empty string', - }, max_output_lines = { config.run_panel.max_output_lines, function(value) diff --git a/lua/cp/ui/panel.lua b/lua/cp/ui/panel.lua index 8f91a17..64082f1 100644 --- a/lua/cp/ui/panel.lua +++ b/lua/cp/ui/panel.lua @@ -237,10 +237,10 @@ function M.toggle_run_panel(is_debug) end setup_keybindings_for_buffer = function(buf) - vim.keymap.set('n', config.run_panel.close_key, function() + vim.keymap.set('n', 'q', function() M.toggle_run_panel() end, { buffer = buf, silent = true }) - vim.keymap.set('n', config.run_panel.toggle_diff_key, function() + vim.keymap.set('n', 't', function() local modes = { 'none', 'git', 'vim' } local current_idx = nil for i, mode in ipairs(modes) do