Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add single_terminal_per_instance option for toggleterm #221

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require("cmake-tools").setup {
direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float'
close_on_exit = false, -- whether close the terminal when exit
auto_scroll = true, -- whether auto scroll to the bottom
single_terminal_per_instance = false, -- single instance, autocloses the opend one, if present
},
overseer = {
new_task_opts = {
Expand Down Expand Up @@ -114,6 +115,7 @@ require("cmake-tools").setup {
direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float'
close_on_exit = false, -- whether close the terminal when exit
auto_scroll = true, -- whether auto scroll to the bottom
single_terminal_per_instance = false, -- single instance, autocloses the opend one, if present
},
overseer = {
new_task_opts = {
Expand Down
2 changes: 2 additions & 0 deletions lua/cmake-tools/const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local const = {
direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float'
close_on_exit = false, -- whether close the terminal when exit
auto_scroll = true, -- whether auto scroll to the bottom
single_terminal_per_instance = false, -- single instance, autocloses the opend one, if present
},
overseer = {
new_task_opts = {
Expand Down Expand Up @@ -77,6 +78,7 @@ local const = {
direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float'
close_on_exit = false, -- whether close the terminal when exit
auto_scroll = true, -- whether auto scroll to the bottom
single_terminal_per_instance = false, -- single instance, autocloses the opend one, if present
},
overseer = {
new_task_opts = {
Expand Down
3 changes: 3 additions & 0 deletions lua/cmake-tools/toggleterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ end

function _toggleterm.run(cmd, env_script, env, args, cwd, opts, on_exit, on_output)
_toggleterm.cmd = cmd .. " " .. table.concat(args, " ")
if opts.single_terminal_per_instance and _toggleterm.term then
_toggleterm.term:close()
end
TheRealLorenz marked this conversation as resolved.
Show resolved Hide resolved
_toggleterm.term = _terminal.Terminal:new({
--[[ env = {}, -- key:value table with environmental variables passed to jobstart() ]]
cmd = _toggleterm.cmd,
Expand Down
Loading