local function open(cmd) local lines = vim.o.lines - vim.o.cmdheight - (vim.o.laststatus > 0 and 1 or 0) local w, h = math.floor(vim.o.columns * 0.95), math.floor(lines * 0.95) local buf = vim.api.nvim_create_buf(false, true) vim.bo[buf].bufhidden = 'wipe' local win = vim.api.nvim_open_win(buf, true, { relative = 'editor', width = w, height = h, row = math.floor((lines - h) / 2), col = math.floor((vim.o.columns - w) / 2), border = 'rounded', }) vim.fn.termopen(cmd, { on_exit = function() pcall(vim.api.nvim_win_close, win, true) end }) end return { open = open }