One floating terminal. A small Neovim plugin that runs your shell in a centered floating window. You can show and hide the window as many times as you want, the shell keeps running in the background.
┌──────────────────────────────────────────┐
│ ╭──────────── floatty ────────────╮ │
│ │ $ make test │ │
│ │ │ │
│ │ │ │
│ ╰─────────────────────────────────╯ │
└──────────────────────────────────────────┘
- Neovim 0.11 or newer
vim.pack.add { 'https://github.com/kalmbach/floatty.nvim' }
require('floatty').setup(){
'kalmbach/floatty.nvim',
config = function()
require('floatty').setup()
end,
}setup() takes a table that is merged with the defaults. These are the
defaults:
require('floatty').setup {
keymaps = {
toggle = '<M-t>',
},
window = {
width = 0.75, -- fraction of the editor width
height = 0.75, -- fraction of the editor height
border = 'rounded',
title = 'floatty',
title_pos = 'center',
},
}- The terminal runs your
shelloption, in Neovim's current working directory. window.widthandwindow.heightare fractions ofcolumnsandlines. The window is resized and re-centered when Neovim is resized.border,titleandtitle_posare passed tonvim_open_win(), see:help nvim_open_win()for the accepted values.- Set
keymaps.toggletofalseto disable it.
| Keys | Mode | What it does |
|---|---|---|
<M-t> |
normal and terminal | Toggle the terminal. From inside the terminal, it hides it without stopping the shell |
<C-\><C-n> |
terminal | Leave terminal mode (Neovim builtin, see :help terminal-input) |
<M-t> is taken from the shell while you are in the terminal. In bash
and zsh that is transpose-words, and fzf's shell integration uses it
for its file picker. Pick another key if you need those.
- One terminal per Neovim. There is a single shell, shared by the whole session.
- Hiding keeps the shell running. The next toggle shows the same session, with its scrollback.
- Opening always puts you in terminal mode, ready to type.
- When the shell exits, the window closes and the buffer is removed. The next toggle starts a fresh shell.
- Quitting Neovim kills the shell, without asking, even if a command is still running in it.
- Hiding returns to the last visited window, Neovim's default when a floating window closes.
:Floatty " Open the terminal (same as :Floatty open)
:Floatty open " Open or focus it
:Floatty hide " Hide it without stopping the shell
:Floatty toggle " Toggle itlocal floatty = require 'floatty'
floatty.open()
floatty.hide()
floatty.toggle()The tests run in headless Neovim with no user config:
make test # all tests
nvim --headless -u NONE -l tests/smoke.lua # one testMIT. See LICENSE.