recording_uAWNXgbd.mp4
I like the concept of vscode terminal, if you are like me, this complement will be the best of your options. Normally I like to stay inside the editor, if I can make coffee in the editor, believe me I would do it. So having an integrated terminal is the most sensible option, however I tried for a long time to use the integrated terminal of neovim and I didn't get used to write so much to do what I wanted, so I tried and tried plugins, which were not for me, I just wanted something simple and usable, without so many complications. Then as other times I started to program and from that Saturday afternoon came out this plugin. I hope you enjoy it and make all your PR's.
By the way, it's called betterTerm, because it's the best for me. But for you it could very well suck. Plugin of just 486 lines!!!.
recording_8to3c6ce.mp4
- Neovim (>= 0.10)
- With Lazy
{
"CRAG666/betterTerm.nvim",
opts = {
-- your options
},
}
- With packer.nvim
use { 'CRAG666/betterTerm.nvim' }
Add the following line to your init.lua (If not use Lazy)
require('betterTerm').setup()
- Tabbed Interface: Manage multiple terminals in a tabbed view within the winbar.
- Mouse Support: Clickable tabs for easy navigation.
- Toggle Terminals: Quickly open and hide terminals.
- Multi-Terminal Management: Easily create, switch between, rename, and manage several terminals.
- Send Commands: Send commands to any terminal directly from Neovim.
- Terminal Selector: Use
vim.ui.select
to pick a terminal from a list. - Dynamic Tab Focus: Bring any terminal to your current tab page, no matter where it was opened.
- Customizable: Extensive options to tailor the look and feel.
The following functions are exposed for you to use:
-
open({id}, {opts})
: Opens, focuses, or creates a terminal. If the terminal is already visible, it hides it.{id}
(string|number|nil): The terminal index (number) or buffer name (string) to open. Defaults toindex_base
.{opts}
(table|nil): Options for opening.cwd
(string): Set the working directory for a new terminal.
-
send({command}, {index}, {press})
: Sends a command to a specific terminal.{command}
(string): The command to execute.{index}
(number|nil): The terminal index. Defaults to1
.{press}
(table|nil):clean
(boolean): Sends<C-l>
to clear the screen before the command.interrupt
(boolean): Sends<C-c>
to interrupt any running process.
-
select()
: Shows a list of open terminals usingvim.ui.select
to switch to or focus one. -
rename()
: Renames the current active terminal. It will prompt for a new name. -
toggle_tabs()
: Toggles the visibility of the terminal tabs in the winbar.
No keymaps are set by default. Here are some recommendations:
local betterTerm = require('betterTerm')
-- Toggle the first terminal (ID defaults to index_base, which is 0)
vim.keymap.set({"n", "t"}, "<C-;>", function() betterTerm.open() end, { desc = "Toggle terminal" })
-- Open a specific terminal
vim.keymap.set({"n", "t"}, "<C-/>", function() betterTerm.open(1) end, { desc = "Toggle terminal 1" })
-- Select a terminal to focus
vim.keymap.set("n", "<leader>tt", betterTerm.select, { desc = "Select terminal" })
-- Rename the current terminal
vim.keymap.set("n", "<leader>tr", betterTerm.rename, { desc = "Rename terminal" })
-- Toggle the tabs bar
vim.keymap.set("n", "<leader>tb", betterTerm.toggle_tabs, { desc = "Toggle terminal tabs" })
You can configure the plugin by passing a table to the setup
function.
-- Example configuration
require('betterTerm').setup {
prefix = "CRAG",
startInserted = false,
position = "right",
size = 80,
jump_tab_mapping = "<A-$tab>", -- Alt+1, Alt+2, ...
}
prefix
(string, default:Term
): Prefix for terminal buffer names. The final name will beprefix (index)
.position
(string, default:bot
): Position to open the terminal (:h opening-window
).size
(number, default:18
): Size of the terminal window.startInserted
(boolean, default:true
): Start in insert mode when a terminal is opened.show_tabs
(boolean, default:true
): Enable/Disable the tabs bar.new_tab_mapping
(string, default:<C-t>
): Mapping to create a new terminal from within a terminal buffer.jump_tab_mapping
(string, default:<C-$tab>
): Mapping to jump to a specific terminal tab.$tab
is replaced with the terminal index.active_tab_hl
(string, default:TabLineSel
): Highlight group for the active tab.inactive_tab_hl
(string, default:TabLine
): Highlight group for inactive tabs.new_tab_hl
(string, default:BetterTermSymbol
): Highlight group for the new tab icon.new_tab_icon
(string, default:+
): Icon for the new tab button.index_base
(number, default:0
): The starting index number for terminals.
require('betterTerm').setup {
prefix = "Term",
position = "bot",
size = 18,
startInserted = true,
show_tabs = true,
new_tab_mapping = "<C-t>",
jump_tab_mapping = "<C-$tab>",
active_tab_hl = "TabLineSel",
inactive_tab_hl = "TabLine",
new_tab_hl = "BetterTermSymbol",
new_tab_icon = "+",
index_base = 0
}
Integration with code_runner.nvim, see for more info.
return {
'CRAG666/betterTerm.nvim',
keys = {
{
mode = { 'n', 't' },
'<C-;>',
function()
require('betterTerm').open()
end,
desc = 'Open BetterTerm 0',
},
{
mode = { 'n', 't' },
'<C-/>',
function()
require('betterTerm').open(1)
end,
desc = 'Open BetterTerm 1',
},
{
'<leader>tt',
function()
require('betterTerm').select()
end,
desc = 'Select terminal',
}
},
opts = {
position = 'bot',
size = 20,
jump_tab_mapping = "<A-$tab>"
},
}
Your help is needed to make this plugin the best of its kind, be free to contribute, criticize (don't be soft) or contribute ideas. All PR's are welcome.
If you have any ideas to improve this project, do not hesitate to make a request, if problems arise, try to solve them and publish them. Don't be so picky I did this in one afternoon