u.nvim/spec/withbuf.lua
Jonathan Apodaca 315ffc9d67
Some checks failed
NeoVim tests / code-quality (push) Failing after 1m25s
Use nix to create environment for testing
2025-05-19 19:01:06 -06:00

12 lines
264 B
Lua

require 'luacov'
local function withbuf(lines, f)
vim.go.swapfile = false
vim.cmd.new()
vim.api.nvim_buf_set_lines(0, 0, -1, false, lines)
local ok, result = pcall(f)
vim.cmd.bdelete { bang = true }
if not ok then error(result) end
end
return withbuf