u.nvim/spec/withbuf.lua
Jonathan Apodaca 81ba1bb96b
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m27s
Use nix to create environment for testing
2025-05-19 19:03:24 -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