From b11a558f66b89731be58f14b124df14d2b087a25 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 3 Jan 2025 15:57:45 +0000 Subject: [PATCH] Add a custom tmux strategy for vim-test --- nvim/plugin/vim-test.lua | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/nvim/plugin/vim-test.lua b/nvim/plugin/vim-test.lua index b82c466..0526070 100644 --- a/nvim/plugin/vim-test.lua +++ b/nvim/plugin/vim-test.lua @@ -1,23 +1,24 @@ -local map = vim.api.nvim_set_keymap +local set = vim.keymap.set local options = { silent = true, } -map("n", "tf", ":TestFile", options) -map("n", "tg", ":TestVisit", options) -map("n", "tl", ":TestLast", options) -map("n", "tn", ":TestNearest", options) -map("n", "ts", ":TestSuite", options) +set("n", "tf", ":TestFile", options) +set("n", "tg", ":TestVisit", options) +set("n", "tl", ":TestLast", options) +set("n", "tn", ":TestNearest", options) +set("n", "ts", ":TestSuite", options) vim.cmd [[ - let test#echo_command = 0 - let test#strategy = "neovim_sticky" - - let g:test#neovim_sticky#kill_previous = 1 - let g:test#neovim_sticky#reopen_window = 1 - let g:test#preserve_screen = 0 - - let test#php#phpunit#executable = './run test' let test#php#phpunit#options = '--colors=always --testdox' + + function! TmuxStrategy(cmd) + let l:escaped_cmd = substitute(a:cmd, ' ', '\\ ', 'g') + + execute 'silent !tmux send-keys -t .bottom ' . l:escaped_cmd . ' Enter' + endfunction + + let g:test#custom_strategies = {'tmux': function('TmuxStrategy')} + let g:test#strategy = 'tmux' ]]