u.nvim/spec/withbuf.lua
Jonathan Apodaca 7fb60add94
All checks were successful
NeoVim tests / plenary-tests (push) Successful in 9s
move away from vim.opt_global to vim.go
2025-03-19 22:29:33 -06:00

11 lines
247 B
Lua

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