Skip to content

Latest commit

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

floatty.nvim

floatty

NeovimVersionLuaLicense

A tiny (<200 LOC) but highly customizable floating terminal plugin. Inspired by toggleterm.nvim but focused on simplicity.

Features

  • Easily toggle floating terminals and custom windows using .toggle(opts).
  • Customize window size, positioning, and appearance.
  • Support for custom terminal commands (e.g lazygit), working directories, and window options.

Requirements

  • Neovim 0.11+

Installation

Install with your favorite package manager. For example, in lazy.nvim:

{ "ingur/floatty.nvim" }

Quickstart

-- initialize configlocalterm=require("floatty").setup({})
-- set toggle keybinds (supports v:count by default!)vim.keymap.set('n', '<C-t>', function() term.toggle() end)
vim.keymap.set('t', '<C-t>', function() term.toggle() end)

Tip

See more config examples below

Defaults

-- NOTE: all options can be functions to be evaluatedlocaldefaults= {
file=nil, -- File to open (if any)cmd=vim.o.shell, -- Terminal command to runcwd=vim.fn.getcwd, -- Working directory of the commandid=function() returnvim.v.countend, -- Identifier for the floatstart_in_insert=true, -- Start in insert modefocus=true, -- Focus the window after openingon_open=nil, -- Callback(config, buf) when buffer is createdon_exit=nil, -- Callback(config, buf) when buffer is destroyedwindow= {
row=nil, -- Supports percentages (<=1) and absolute sizes (>1)col=nil, -- Supports percentages (<=1) and absolute sizes (>1)width=0.8, -- Supports percentages (<=1) and absolute sizes (>1)height=0.8, -- Supports percentages (<=1) and absolute sizes (>1)h_align="center", -- "left", "center", "right" (used when col is nil)v_align="center", -- "top", "center", "bottom" (used when row is nil)border="rounded", -- Border stylezindex=50, -- Z-index of the floattitle="", -- window titletitle_pos="center", -- "left", "center", "right"-- see :h nvim_open_win() for more config options
},
wo= { -- Window-local optionscursorcolumn=false,
cursorline=false,
cursorlineopt="both",
fillchars="eob: ,lastline:…",
list=false,
listchars="extends:…,tab: ",
number=false,
relativenumber=false,
signcolumn="no",
spell=false,
winbar="",
statuscolumn="",
wrap=false,
sidescrolloff=0,
-- other window options are also supported
},
}

Config examples

Bottom-aligned Terminal

localterm=require("floatty").setup({
window= {
row=function() returnvim.o.lines-11end,
width=1.0,
height=8,
},
})
vim.keymap.set('n', '<C-t>', function() term.toggle() end)
vim.keymap.set('t', '<C-t>', function() term.toggle() end)

Lazygit float

locallazygit=require("floatty").setup({
cmd="lazygit",
id=vim.fn.getcwd, -- Use the current working directory as the float's ID
})
vim.keymap.set('n', '<C-g>', function() lazygit.toggle() end)
vim.keymap.set('t', '<C-g>', function() lazygit.toggle() end)

Toggling Between Horizontal and Vertical Layouts

localterm=require("floatty").setup()
locallayout="horizontal"term.toggle_layout=function()
layout=layout=="horizontal" and"vertical" or"horizontal"iflayout=="horizontal" thenterm.window= {
row=function() returnvim.o.lines-11end,
width=1.0,
height=8,
h_align="center",
}
elseterm.window= {
row=nil,
height=function() returnvim.o.lines-3end,
width=0.25,
h_align="right",
v_align="top",
}
endendvim.keymap.set('n', '<leader>tt', term.toggle_layout)

About

A tiny (<200 LOC) but highly customizable floating terminal manager.

Topics

Resources

Stars

30 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages