diff --git a/lua/astrocommunity/utility/toggleterm-manager/README.md b/lua/astrocommunity/terminal-integration/toggleterm-manager-nvim/README.md similarity index 54% rename from lua/astrocommunity/utility/toggleterm-manager/README.md rename to lua/astrocommunity/terminal-integration/toggleterm-manager-nvim/README.md index b49734187..30c510f7c 100644 --- a/lua/astrocommunity/utility/toggleterm-manager/README.md +++ b/lua/astrocommunity/terminal-integration/toggleterm-manager-nvim/README.md @@ -1,10 +1,10 @@ -# toggleterm-mamnager.nvim +# toggleterm-manager.nvim -Manage your toggleterm terminal buffers with telescope. Additional keybindings are added in the Telescope interface to +A Telescope extension to manage Toggleterm's terminals in NeoVim Key `ts` is mapped to open the telescope interface. -Keymaps in the Telescope interface: +Additionally added keymaps in the Telescope interface: - `n` normal mode: - ``: toggle the selected terminal. @@ -17,10 +17,4 @@ Keymaps in the Telescope interface: - ``: delete the selected terminal. - ``: create a new terminal buffer -Dependencies: - -- [akinsho/nvim-toggleterm.lua](https://github.com/akinsho/toggleterm.nvim) -- [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) -- [nvim-lua/plenary.nvim](https://github.com/nvim-lua/plenary.nvim) - **Repository:** diff --git a/lua/astrocommunity/terminal-integration/toggleterm-manager-nvim/init.lua b/lua/astrocommunity/terminal-integration/toggleterm-manager-nvim/init.lua new file mode 100644 index 000000000..3f0e26c61 --- /dev/null +++ b/lua/astrocommunity/terminal-integration/toggleterm-manager-nvim/init.lua @@ -0,0 +1,37 @@ +return { + "ryanmsnyder/toggleterm-manager.nvim", + init = function(plugin) require("astrocore").on_load("telescope.nvim", plugin.name) end, + dependencies = { + "akinsho/toggleterm.nvim", + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + { + "AstroNvim/astrocore", + opts = { + mappings = { + n = { + ["ts"] = { "Telescope toggleterm_manager", desc = "Search Toggleterms" }, + }, + }, + }, + }, + }, + opts = function(_, opts) + local term_icon = require("astroui").get_icon "Terminal" + local toggleterm_manager = require "toggleterm-manager" + local actions = toggleterm_manager.actions + + return require("astrocore").extend_tbl(opts, { + titles = { prompt = term_icon .. " Terminals" }, + results = { term_icon = term_icon }, + mappings = { + n = { + [""] = { action = actions.toggle_term, exit_on_action = true }, -- toggles terminal open/closed + ["r"] = { action = actions.rename_term, exit_on_action = false }, -- provides a prompt to rename a terminal + ["d"] = { action = actions.delete_term, exit_on_action = false }, -- deletes a terminal buffer + ["n"] = { action = actions.create_term, exit_on_action = false }, -- creates a new terminal buffer + }, + }, + }) + end, +} diff --git a/lua/astrocommunity/utility/toggleterm-manager/init.lua b/lua/astrocommunity/utility/toggleterm-manager/init.lua deleted file mode 100644 index 191bc3dc6..000000000 --- a/lua/astrocommunity/utility/toggleterm-manager/init.lua +++ /dev/null @@ -1,50 +0,0 @@ -return { - { - "ryanmsnyder/toggleterm-manager.nvim", - opts = function(_, opts) - local toggleterm_manager = require "toggleterm-manager" - local actions = toggleterm_manager.actions - - local mappings = { - i = { - [""] = { action = actions.toggle_term, exit_on_action = true }, -- toggles terminal open/closed - [""] = { action = actions.create_term, exit_on_action = false }, -- creates a new terminal buffer - [""] = { action = actions.delete_term, exit_on_action = false }, -- deletes a terminal buffer - [""] = { action = actions.rename_term, exit_on_action = false }, -- provides a prompt to rename a terminal - }, - n = { - [""] = { action = actions.toggle_term, exit_on_action = true }, -- toggles terminal open/closed - ["r"] = { action = actions.rename_term, exit_on_action = false }, -- provides a prompt to rename a terminal - ["d"] = { action = actions.delete_term, exit_on_action = false }, -- deletes a terminal buffer - ["n"] = { action = actions.create_term, exit_on_action = false }, -- creates a new terminal buffer - }, - } - - if not opts.mappings then - opts.mappings = mappings - else - opts.mappings = vim.tbl_deep_extend("force", opts.mappings, mappings) - end - end, - - config = function(_, opts) - local toggleterm_manager = require "toggleterm-manager" - toggleterm_manager.setup(opts) - end, - dependencies = { - "akinsho/nvim-toggleterm.lua", - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", -- only needed because it's a dependency of telescope - { - "AstroNvim/astrocore", - opts = { - mappings = { - n = { - ["ts"] = { "Telescope toggleterm_manager", desc = "Toggleterm" }, - }, - }, - }, - }, - }, - }, -}