Skip to content

Commit

Permalink
feat(utility): add toggleterm-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
LumenYoung committed May 13, 2024
1 parent bbf59b2 commit 54b9d26
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lua/astrocommunity/utility/toggleterm-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# toggleterm-mamnager.nvim

Manage your toggleterm terminal buffers with telescope. Additional keybindings are added in the Telescope interface to

Key `<Leader>ts` is mapped to open the telescope interface.

Keymaps in the Telescope interface:

- `n` normal mode:
- `<CR>`: toggle the selected terminal.
- `r`: rename the selected terminal.
- `d`: delete the selected terminal.
- `n`: create a new terminal buffer
- `i` insert mode:
- `<CR>`: toggle the selected terminal.
- `<C-r>`: rename the selected terminal.
- `<C-d>`: delete the selected terminal.
- `<C-i>`: 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:** <https://github.com/ryanmsnyder/toggleterm-manager.nvim>
50 changes: 50 additions & 0 deletions lua/astrocommunity/utility/toggleterm-manager/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
return {
{
"ryanmsnyder/toggleterm-manager.nvim",
opts = function(_, opts)
local toggleterm_manager = require "toggleterm-manager"
local actions = toggleterm_manager.actions

local mappings = {
i = {
["<CR>"] = { action = actions.toggle_term, exit_on_action = true }, -- toggles terminal open/closed
["<C-i>"] = { action = actions.create_term, exit_on_action = false }, -- creates a new terminal buffer
["<C-d>"] = { action = actions.delete_term, exit_on_action = false }, -- deletes a terminal buffer
["<C-r>"] = { action = actions.rename_term, exit_on_action = false }, -- provides a prompt to rename a terminal
},
n = {
["<CR>"] = { 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 = {
["<Leader>ts"] = { "<cmd>Telescope toggleterm_manager<cr>", desc = "Toggleterm" },
},
},
},
},
},
},
}

0 comments on commit 54b9d26

Please sign in to comment.