@@ -40,10 +40,12 @@ function _terminal.show(opts)
4040 if win_id ~= - 1 then
4141 -- The window is alive, so we set buffer in window
4242 vim .api .nvim_win_set_buf (win_id , _terminal .id )
43- if opts .split_direction == " horizontal" then
44- vim .api .nvim_win_set_height (win_id , opts .split_size )
45- else
46- vim .api .nvim_win_set_width (win_id , opts .split_size )
43+ if opts .auto_resize then
44+ if opts .split_direction == " horizontal" then
45+ vim .api .nvim_win_set_height (win_id , opts .split_size )
46+ else
47+ vim .api .nvim_win_set_width (win_id , opts .split_size )
48+ end
4749 end
4850 elseif win_id >= - 1 then
4951 -- The window is not active, we need to create a new buffer
@@ -63,6 +65,11 @@ function _terminal.new_instance(term_name, opts)
6365 vim .cmd (" :" .. opts .split_direction .. " " .. opts .split_size .. " sp | :term" ) -- Creater terminal in a split
6466 -- local new_name = vim.fn.fnamemodify(term_name, ":t") -- Extract only the terminal name and reassign it
6567 vim .api .nvim_buf_set_name (vim .api .nvim_get_current_buf (), term_name ) -- Set the buffer name
68+ if opts .split_direction == " horizontal" then
69+ vim .wo .winfixheight = true
70+ else
71+ vim .wo .winfixwidth = true
72+ end
6673 vim .cmd (" :setlocal laststatus=3" ) -- Let there be a single status/lualine in the neovim instance
6774
6875 -- Renamming a terminal buffer creates a new hidden buffer, so duplicate terminals need to be deleted
@@ -165,10 +172,12 @@ function _terminal.send_data_to_terminal(buffer_idx, cmd, opts)
165172 if opts and opts .win_id ~= - 1 then
166173 -- The window is alive, so we set buffer in window
167174 vim .api .nvim_win_set_buf (opts .win_id , buffer_idx )
168- if opts .split_direction == " horizontal" then
169- vim .api .nvim_win_set_height (opts .win_id , opts .split_size )
170- else
171- vim .api .nvim_win_set_width (opts .win_id , opts .split_size )
175+ if opts .auto_resize then
176+ if opts .split_direction == " horizontal" then
177+ vim .api .nvim_win_set_height (opts .win_id , opts .split_size )
178+ else
179+ vim .api .nvim_win_set_width (opts .win_id , opts .split_size )
180+ end
172181 end
173182 elseif opts and opts .win_id >= - 1 then
174183 -- The window is not active, we need to create a new buffer
@@ -628,6 +637,7 @@ function _terminal.run(cmd, env_script, env, args, cwd, opts, on_exit, on_output
628637 split_size = opts .split_size ,
629638 start_insert = opts .start_insert ,
630639 focus = opts .focus ,
640+ auto_resize = opts .auto_resize ,
631641 do_not_add_newline = opts .do_not_add_newline ,
632642 }
633643 )
0 commit comments