add convenient keymaps for test-command inspection
This commit is contained in:
@@ -76,6 +76,8 @@ local function help_lines()
|
||||
" <C-h> Focus Test-Listing-Float",
|
||||
" <leader>z Toggle Detail-Float full width",
|
||||
" <leader>o Jump to test location",
|
||||
" <leader>cb breaks test-command onto multiple lines",
|
||||
" <leader>cj joins test-command onto single line",
|
||||
" ? Show this help",
|
||||
"",
|
||||
"Testing-Float (Detail):",
|
||||
@@ -139,6 +141,16 @@ local function apply_listing_lines(buf, lines)
|
||||
rebuild_result_line_map(lines)
|
||||
end
|
||||
|
||||
local function apply_listing_substitution(command)
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if not (buf and vim.api.nvim_buf_is_valid(buf)) then
|
||||
return
|
||||
end
|
||||
vim.api.nvim_buf_call(buf, function()
|
||||
vim.cmd(command)
|
||||
end)
|
||||
end
|
||||
|
||||
local function apply_listing_filter(kind)
|
||||
if not (state.last_buf and vim.api.nvim_buf_is_valid(state.last_buf)) then
|
||||
return
|
||||
@@ -766,6 +778,12 @@ local function create_output_win(initial_lines)
|
||||
vim.keymap.set("n", "<leader>pf", function()
|
||||
jump_listing_fail("prev")
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>cb", function()
|
||||
M.listing_break_on_dashes()
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>cj", function()
|
||||
M.listing_join_backslashes()
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>o", function()
|
||||
jump_to_listing_test()
|
||||
end, { buffer = buf, nowait = true, silent = true })
|
||||
@@ -845,6 +863,12 @@ local function reopen_output_win()
|
||||
vim.keymap.set("n", "<leader>pf", function()
|
||||
jump_listing_fail("prev")
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>cb", function()
|
||||
M.listing_break_on_dashes()
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>cj", function()
|
||||
M.listing_join_backslashes()
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>o", function()
|
||||
jump_to_listing_test()
|
||||
end, { buffer = state.last_buf, nowait = true, silent = true })
|
||||
@@ -1332,6 +1356,14 @@ function M.filter_listing_all()
|
||||
apply_listing_filter("all")
|
||||
end
|
||||
|
||||
function M.listing_break_on_dashes()
|
||||
apply_listing_substitution([[%s/--/\\\r\t--/g]])
|
||||
end
|
||||
|
||||
function M.listing_join_backslashes()
|
||||
apply_listing_substitution([[%s/\\\n\t//g]])
|
||||
end
|
||||
|
||||
function M.run_test_at_cursor()
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
local line = cursor[1]
|
||||
|
||||
Reference in New Issue
Block a user