diff --git a/lua/terminal.lua b/lua/terminal.lua index 6ac792f..c49f77b 100644 --- a/lua/terminal.lua +++ b/lua/terminal.lua @@ -1,11 +1,22 @@ local M = {} ---- Opens a TUI application in a new scratch buffer and deletes the buffer on exit. +--- Opens a TUI application in a simple centered floating window. function M.open_terminal_app(cmd) - vim.cmd("enew") + local buf = vim.api.nvim_create_buf(false, true) + + -- Open a centered floating window (80% screen width/height) + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = math.floor(vim.o.columns * 0.95), + height = math.floor(vim.o.lines * 0.95), + row = math.floor(vim.o.lines * 0.025), + col = math.floor(vim.o.columns * 0.025), + border = "rounded", + }) + vim.fn.termopen(cmd, { on_exit = function() - pcall(vim.cmd, "bdelete!") + pcall(vim.api.nvim_win_close, win, true) end, }) end