-- One terminal at the bottom that opens and closes; what runs in it keeps running. local M = {} local state = { buf = nil, win = nil } function M.toggle() if state.win and vim.api.nvim_win_is_valid(state.win) then vim.api.nvim_win_hide(state.win) state.win = nil return end vim.cmd("botright " .. math.max(8, math.floor(vim.o.lines * 0.3)) .. "split") state.win = vim.api.nvim_get_current_win() if state.buf and vim.api.nvim_buf_is_valid(state.buf) then vim.api.nvim_win_set_buf(state.win, state.buf) else vim.cmd.terminal() state.buf = vim.api.nvim_get_current_buf() vim.bo[state.buf].buflisted = false end vim.wo[state.win].number = false vim.wo[state.win].signcolumn = "no" vim.cmd.startinsert() end --- Run a command of the IDE's own in a terminal split and leave its output on the screen. function M.run(argv) vim.cmd("botright " .. math.max(12, math.floor(vim.o.lines * 0.45)) .. "new") local buf = vim.api.nvim_get_current_buf() vim.bo[buf].bufhidden = "wipe" if vim.fn.has("nvim-0.11") == 1 then vim.fn.jobstart(argv, { term = true }) else vim.fn.termopen(argv) end vim.bo[buf].buflisted = false vim.keymap.set("n", "q", "bwipeout!", { buffer = buf, nowait = true }) end return M