Neovim terminal Plugin (inspired by NvChad/nvterm)
{
"oroszarnold12/nvim-simpleterm",
config = function ()
require("simpleterm").setup()
end,
}
- Pass a table of configuration options to the plugin's
.setup()
function above. - Default configuration table
require("nvterm").setup({
type_opts = {
horizontal = { location = "rightbelow", split_ratio = 0.3 },
vertical = { location = "rightbelow", split_ratio = 0.5 },
floating = {
relative = "editor",
row = 0.3,
col = 0.25,
width = 0.5,
height = 0.4,
border = "single",
},
},
behavior = {
autoclose_on_quit = {
enabled = false,
confirm = true,
},
close_on_exit = true,
auto_insert = true,
},
})
Map the functions below to your prefered keys
require("simpleterm.terminal").toggle_horizontal()
require("simpleterm.terminal").toggle_vertical()
require("simpleterm.terminal").toggle_floating()
require("simpleterm.terminal").new_horizontal()
require("simpleterm.terminal").new_vertical()
require("simpleterm.terminal").new_floating()
It is possible to spawn multiple horizontal/vertical/floating terminals. You can cycle through the different terminals inside the current window with the function below
require("simpleterm.terminal").next_term_buffer()
{
"oroszarnold12/nvim-simpleterm",
keys = { "<A-h>", "<A-v>", "<A-i>", "<leader>h", "<leader>v", "<leader>i" },
config = function()
require("simpleterm").setup()
local term = require("simpleterm.terminal")
vim.keymap.set("t", "<S-TAB>", term.next_term_buffer, { desc = "Next Terminal Buffer" })
vim.keymap.set("t", "<A-h>", term.toggle_horizontal, { desc = "Toggle Horizontal Terminal" })
vim.keymap.set("t", "<A-v>", term.toggle_vertical, { desc = "Toggle Vertical Terminal" })
vim.keymap.set("t", "<A-i>", term.toggle_floating, { desc = "Toggle Floating Terminal" })
vim.keymap.set("n", "<A-h>", term.toggle_horizontal, { desc = "Toggle Horizontal Terminal" })
vim.keymap.set("n", "<A-v>", term.toggle_vertical, { desc = "Toggle Vertical Terminal" })
vim.keymap.set("n", "<A-i>", term.toggle_floating, { desc = "Toggle Floating Terminal" })
vim.keymap.set("n", "<leader>h", term.new_horizontal, { desc = "New Horizontal Terminal" })
vim.keymap.set("n", "<leader>v", term.new_vertical, { desc = "New Vertical Terminal" })
vim.keymap.set("n", "<leader>i", term.new_floating, { desc = "new Floating Terminal" })
end,
}