neoterm.nvim
neoterm.nvim copied to clipboard
Neovim lua plugin for managing a floating terminal window
Neoterm
Simple neovim terminal plugin written in lua. Terminal runs in a floating window in a configurable position.
Requires neovim
0.7+ for access to the lua autocmd API.
Usage
Neoterm provides both vim commands as well as a lua API
Commands
Neoterm provides the following commands
Command | Description |
---|---|
NeotermOpen |
Open the neoterm window |
NeotermClose |
Close the neoterm window |
NeotermToggle |
Toggle the neoterm window |
NeotermRun <args> |
Run the given command in the neoterm window |
NeotermRerun |
Run the previous command again |
NeotermExit |
Close the neoterm window and delete the terminal buffer |
Lua API
The following functions are available on the neoterm module. They map directly to the commands above
-- Setup global config
require('neoterm').setup({
clear_on_run = true, -- run clear command before user specified commands
mode = 'vertical', -- vertical/horizontal/fullscreen
noinsert = false -- disable entering insert mode when opening the neoterm window
})
local neoterm = require('neoterm')
neoterm.open()
-- Override global config on a specific open call
neoterm.open({ mode = 'horizontal', noinsert = true})
neoterm.close()
neoterm.toggle()
neoterm.run('ls')
-- Control whether or not the screen is cleared before running the command
neoterm.run('ls', {clear = false})
neoterm.rerun()
neoterm.exit()
Example Keybindings
nnoremap <leader>tt <cmd>NeotermToggle<CR>
nnoremap <leader>tr :NeotermRun<space>
nnoremap <leader>tR <cmd>NeotermRerun<CR>
nnoremap <leader>tx <cmd>NeotermExit<CR>
tnoremap <leader>tn <C-\\><C-n>
tnoremap <leader>tt <cmd>NeotermToggle<CR>
tnoremap <leader>tx <cmd>NeotermExit<CR>
Screenshots
Vertical (default)
require('neoterm').open()
-- or
require('neoterm').open({mode ='vertical'})
Horizontal
require('neoterm').open({mode ='horizontal'})
Fullscreen
require('neoterm').open({mode ='fullscreen'})