Files
neovim-config/lua/terminal.lua
T
2026-09-03 20:27:45 +02:00

24 lines
588 B
Lua

local M = {}
--- Opens a command in a simple centered floating window.
function M.open_terminal_app(cmd)
local buf = vim.api.nvim_create_buf(false, true)
local w = math.floor(vim.o.columns * 0.95)
local h = math.floor(vim.o.lines * 0.95)
local win = vim.api.nvim_open_win(buf, true, {
relative = "editor",
width = w,
height = h,
row = math.floor((vim.o.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 M