This is a plugin.nvim version of my previous "pseudo-plugin":
toggle_term.lua
Cleaned it up a little (and merged the tiny 'modules')
Note
This is the primary (dev)development branch and will probably be very chaotic.
Please just use main branch instead.
First add it to you favorite plugin-manager
-- Together with other files -- if standalone file, just remove on set fo `{}`
return {
-- ... other plugins
{
'LibereCode/toggleTerm.nvim',
opts = function(_, opts)
-- create terminal(s) and set keymap (examples:)
local map, tTerm = vim.keymap.set, require('toggleTerm')
local terminal = tTerm.new()
map({ 'n', 't' }, '<M-t>', function()
terminal:toggle_float({ border = 'single' })
end, { desc = 'toggle floating term' })
map({ 'n', 't' }, '<M-t>', function()
terminal:toggle_hor({ y = 0.4 })
end, { desc = 'togHor' })
-- can also create other terminal instances by just
-- running `local newVar = tTerm.new()` again
end,
},
-- ... other plugins
}-- This is the builtin package manager for nvim. see `:h vim.pack`
vim.pack.add({
-- ... other plugins
'https://github.com/LibereCode/toggleTerm.nvim',
-- ... other plugins
})
local tTerm = require('toggleTerm')
tTerm.setup(function())
terminal = tTerm.new()
end)
-- set keymap
vim.keymap.set({ 'n', 't' }, '<M-t>', function()
terminal:toggle_float({ x = 0.7, y = 0.95 })
end, { desc = 'toggle floating terminal and make this desc shorter.' })
Possible values for opts in toggle_[float|hor](opts):
x = number(0 <= number <= 1) # the widthy = number(0 <= number <= 1) # the heightborder = string(string mentioned in:help winborder)
- Fix type annotation, so that you get hints about opts in
toggle_term(opts) - Do (maybe?) a
setup()function - Make
:helpdocs