From b44a963f3703cb2db5157a227ad619b366be0332 Mon Sep 17 00:00:00 2001 From: TheRealLorenz Date: Wed, 1 May 2024 12:03:59 +0200 Subject: [PATCH 1/4] feat: single_terminal_per_instance for toggleterm --- README.md | 2 ++ lua/cmake-tools/const.lua | 2 ++ lua/cmake-tools/toggleterm.lua | 3 +++ 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 0cc70e9a..2d91e35c 100644 --- a/README.md +++ b/README.md @@ -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 = { @@ -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 = { diff --git a/lua/cmake-tools/const.lua b/lua/cmake-tools/const.lua index 52c1a119..7f081ecc 100644 --- a/lua/cmake-tools/const.lua +++ b/lua/cmake-tools/const.lua @@ -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 = { @@ -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 = { diff --git a/lua/cmake-tools/toggleterm.lua b/lua/cmake-tools/toggleterm.lua index 27f90729..dca20e11 100644 --- a/lua/cmake-tools/toggleterm.lua +++ b/lua/cmake-tools/toggleterm.lua @@ -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 _toggleterm.term = _terminal.Terminal:new({ --[[ env = {}, -- key:value table with environmental variables passed to jobstart() ]] cmd = _toggleterm.cmd, From 1dab5106deba24257177405fa3286b6a8d12a486 Mon Sep 17 00:00:00 2001 From: TheRealLorenz Date: Wed, 1 May 2024 14:47:22 +0200 Subject: [PATCH 2/4] Fix typo --- README.md | 4 ++-- lua/cmake-tools/const.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2d91e35c..ea49b1b6 100644 --- a/README.md +++ b/README.md @@ -65,7 +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 + single_terminal_per_instance = false, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { @@ -115,7 +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 + single_terminal_per_instance = false, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { diff --git a/lua/cmake-tools/const.lua b/lua/cmake-tools/const.lua index 7f081ecc..b5a6bdf9 100644 --- a/lua/cmake-tools/const.lua +++ b/lua/cmake-tools/const.lua @@ -35,7 +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 + single_terminal_per_instance = false, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { @@ -78,7 +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 + single_terminal_per_instance = false, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { From 77f23b84ea16b81da05a0947c1ad35b5b3384258 Mon Sep 17 00:00:00 2001 From: TheRealLorenz Date: Wed, 1 May 2024 14:49:31 +0200 Subject: [PATCH 3/4] Set single_terminal as default for toggleterm --- README.md | 4 ++-- lua/cmake-tools/const.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ea49b1b6..23dc0d0f 100644 --- a/README.md +++ b/README.md @@ -65,7 +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 opened one, if present + single_terminal_per_instance = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { @@ -115,7 +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 opened one, if present + single_terminal_per_instance = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { diff --git a/lua/cmake-tools/const.lua b/lua/cmake-tools/const.lua index b5a6bdf9..1a92f549 100644 --- a/lua/cmake-tools/const.lua +++ b/lua/cmake-tools/const.lua @@ -35,7 +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 opened one, if present + single_terminal_per_instance = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { @@ -78,7 +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 opened one, if present + single_terminal_per_instance = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { From 6f414e58bdc85f6be9cc1690393fc41a8b30ecae Mon Sep 17 00:00:00 2001 From: TheRealLorenz Date: Thu, 2 May 2024 08:49:35 +0200 Subject: [PATCH 4/4] Rename single_terminal_per_instance to singleton --- README.md | 4 ++-- lua/cmake-tools/const.lua | 4 ++-- lua/cmake-tools/toggleterm.lua | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 23dc0d0f..5439e86e 100644 --- a/README.md +++ b/README.md @@ -65,7 +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 = true, -- single instance, autocloses the opened one, if present + singleton = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { @@ -115,7 +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 = true, -- single instance, autocloses the opened one, if present + singleton = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { diff --git a/lua/cmake-tools/const.lua b/lua/cmake-tools/const.lua index 1a92f549..29ad2ed2 100644 --- a/lua/cmake-tools/const.lua +++ b/lua/cmake-tools/const.lua @@ -35,7 +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 = true, -- single instance, autocloses the opened one, if present + singleton = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { @@ -78,7 +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 = true, -- single instance, autocloses the opened one, if present + singleton = true, -- single instance, autocloses the opened one, if present }, overseer = { new_task_opts = { diff --git a/lua/cmake-tools/toggleterm.lua b/lua/cmake-tools/toggleterm.lua index dca20e11..8255a873 100644 --- a/lua/cmake-tools/toggleterm.lua +++ b/lua/cmake-tools/toggleterm.lua @@ -24,7 +24,7 @@ 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 + if opts.singleton and _toggleterm.term then _toggleterm.term:close() end _toggleterm.term = _terminal.Terminal:new({