90 lines
2.3 KiB
Lua
90 lines
2.3 KiB
Lua
local last_test = {}
|
|
return {
|
|
{
|
|
'samharju/yeet.nvim',
|
|
opts = {
|
|
clear_before_yeet = false,
|
|
interrupt_before_yeet = true,
|
|
yeet_and_run = true,
|
|
notify_on_success = true,
|
|
custom_eval = function(cmd_string)
|
|
if cmd_string:match '#test' then
|
|
-- get current win's filetype
|
|
local ft = vim.bo[0].filetype
|
|
|
|
if ft == 'go' then
|
|
local dap_go = require 'dap-go-ts'
|
|
local test = dap_go.closest_test()
|
|
if not (test.name == nil or test.name == '') then
|
|
last_test = test
|
|
end
|
|
end
|
|
|
|
if next(last_test) ~= nil and not (last_test.name == nil or last_test.name == '') then
|
|
cmd_string = cmd_string:gsub('#test', last_test.name)
|
|
else
|
|
vim.notify('Aborting run, no test found', vim.log.levels.WARN)
|
|
return ''
|
|
end
|
|
end
|
|
|
|
if cmd_string:match '#cwd' then
|
|
local cwd = vim.fn.getcwd()
|
|
|
|
cmd_string = cmd_string:gsub('#cwd', cwd)
|
|
end
|
|
|
|
if cmd_string:match '#file' then
|
|
local file = vim.api.nvim_buf_get_name(0)
|
|
|
|
cmd_string = cmd_string:gsub('#file', file)
|
|
end
|
|
|
|
return cmd_string
|
|
end,
|
|
},
|
|
keys = {
|
|
{
|
|
-- Open target selection
|
|
'<leader>yt',
|
|
function()
|
|
require('yeet').select_target()
|
|
end,
|
|
desc = 'Open yeet target select',
|
|
},
|
|
{
|
|
-- Douple tap \ to yeet at something
|
|
'\\\\',
|
|
function()
|
|
require('yeet').execute()
|
|
end,
|
|
desc = 'Yeet',
|
|
},
|
|
{
|
|
-- Toggle autocommand for yeeting after write
|
|
'<leader>yo',
|
|
function()
|
|
require('yeet').toggle_post_write()
|
|
if vim.g.yeetaucmd then
|
|
vim.g.yeetaucmd = false
|
|
vim.notify 'disabled yeet aucmd'
|
|
else
|
|
vim.g.yeetaucmd = true
|
|
vim.notify 'enabled yeet aucmd'
|
|
end
|
|
end,
|
|
desc = 'Toggle post write yeet aucmd',
|
|
},
|
|
{
|
|
-- Yeet visual selection. Useful sending core to a repl or running multiple commands.
|
|
'<leader>yv',
|
|
function()
|
|
require('yeet').execute_selection { clear_before_yeet = false }
|
|
end,
|
|
mode = { 'n', 'v' },
|
|
desc = 'Yeet selected text',
|
|
},
|
|
},
|
|
},
|
|
}
|