neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

commit 3f7bb3ee5ecd5404a414e4b0fb7c89a2784f3d43
parent 78e63936f47bca01ae528ccfb9e7d98a370eb7fe
Author: Tomas Nemec <owl@gtms.dev>
Date:   Mon, 28 Jul 2025 18:21:13 +0200

fix: terminal creates multiple

Diffstat:
Mlua/tms/p/terminal.lua | 33+++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/lua/tms/p/terminal.lua b/lua/tms/p/terminal.lua @@ -1,7 +1,6 @@ --- Dispatchers for LSP message types. --- @class (private) State --- @field win integer? ---- @field last_win integer? --- @field buf integer --- @field chan integer --- @field last_command string? @@ -19,29 +18,31 @@ end local M = {} M.toggle = function() - State.last_win = vim.api.nvim_get_current_win() - if State:is_open() then vim.api.nvim_win_close(State.win, true) State.win = nil return end - if not State:is_valid() then - State.buf = vim.api.nvim_create_buf(false, true) - end + if State:is_valid() then + State.win = vim.api.nvim_open_win(State.buf, false, { split = 'below', height = 12 }) + + vim.api.nvim_set_current_win(State.win) - State.win = vim.api.nvim_open_win(State.buf, false, { split = 'below', height = 12 }) + vim.cmd.normal('G') + vim.cmd.wincmd('p') + else + State.buf = vim.api.nvim_create_buf(false, true) + State.win = vim.api.nvim_open_win(State.buf, false, { split = 'below', height = 12 }) - -- NOT WORKING - -- print(vim.api.nvim_open_term(State.buf, {})) + vim.api.nvim_set_current_win(State.win) + vim.cmd.term() + State.chan = vim.opt.channel:get() + vim.api.nvim_buf_set_name(State.buf, 'terminal') - vim.api.nvim_set_current_win(State.win) - vim.cmd.term() - State.chan = vim.opt.channel:get() - vim.api.nvim_buf_set_name(State.buf, 'terminal') - vim.cmd.normal('G') - vim.cmd.wincmd('w') + vim.cmd.normal('G') + vim.cmd.wincmd('p') + end end -- Closes the window and deletes the buffer. This entirely resets the term state @@ -92,7 +93,7 @@ M.interactive = function() end if vim.api.nvim_get_current_win() == State.win then - vim.cmd.wincmd('w') + vim.cmd.wincmd('p') else vim.api.nvim_set_current_win(State.win) vim.cmd.startinsert()