🧼 A neovim plugin for cleeean neovim window (and tmux pane) functions. 🧼
Works with or without tmux!
<leader>z
to toggle maximizing the current neovim window (without any of
the ugly borders that other maximizing plugins create) AND the current
tmux pane.Note: Please see maximize.nvim for using just the window maximizing feature.
<C-\>
to toggle the (improved) native terminal which will open
fullscreen. (See the demo video below)<leader>{motion}
to switch to the window (or tmux pane) in the specified
direction.<leader>x{motion}
to save and quit the window (or kill the tmux pane) in
the specified direction.<leader>;
to jump to the previous window (or tmux pane).Note: The {motion} keys by default are h, j, k and l, but can be replaced with the arrow keys. See 'Configuration' for details.
Has weird thing in the top left where it didn't maximize properly and doesn't maximize the tmux pane. 🤢
Perfectly maximizes the neovim window and tmux pane! 👑
Install with your favourite plugin manager and run the setup function.
Note: I highly recommend using bufresize.nvim especially when using tmux.
use {
'declancm/windex.nvim',
config = function() require('windex').setup() end
}
A settings table can be passed into the setup function for custom options.
-- KEYMAPS:
default_keymaps = true, -- Enable default keymaps.
extra_keymaps = false, -- Enable extra keymaps.
arrow_keys = false, -- Default window movement keymaps use arrow keys instead of 'h,j,k,l'.
-- OPTIONS:
numbered_term = false, -- Enable line numbers in the terminal.
save_buffers = false, -- Save all buffers before switching tmux panes.
warnings = true, -- Enable warnings before some actions such as closing tmux panes.
require('windex').setup {
extra_keymaps = true,
save_buffers = true,
}
Note: If the tmux requirement is not passed, the non-tmux keymaps will be used instead.
-- MAXIMIZE:
-- Toggle maximizing the current window:
vim.keymap.set('n', '<Leader>z', "<Cmd>lua require('windex').toggle_maximize()<CR>")
-- TERMINAL:
-- Toggle the terminal:
vim.keymap.set({ 'n', 't' }, '<C-Bslash>', "<Cmd>lua require('windex').toggle_terminal()<CR>")
-- Enter normal mode within terminal:
vim.keymap.set('t', '<C-n>', '<C-Bslash><C-n>')
-- MOVEMENT:
-- Move between nvim windows and tmux panes:
vim.keymap.set('n', '<Leader>k', "<Cmd>lua require('windex').switch_window('up')<CR>")
vim.keymap.set('n', '<Leader>j', "<Cmd>lua require('windex').switch_window('down')<CR>")
vim.keymap.set('n', '<Leader>h', "<Cmd>lua require('windex').switch_window('left')<CR>")
vim.keymap.set('n', '<Leader>l', "<Cmd>lua require('windex').switch_window('right')<CR>")
-- Save and close the nvim window or kill the tmux pane in the direction selected:
vim.keymap.set('n', '<Leader>xk', "<Cmd>lua require('windex').close_window('up')<CR>")
vim.keymap.set('n', '<Leader>xj', "<Cmd>lua require('windex').close_window('down')<CR>")
vim.keymap.set('n', '<Leader>xh', "<Cmd>lua require('windex').close_window('left')<CR>")
vim.keymap.set('n', '<Leader>xl', "<Cmd>lua require('windex').close_window('right')<CR>")
-- Switch to previous nvim window or tmux pane:
vim.keymap.set('n', '<Leader>;', "<Cmd>lua require('windex').previous_window()<CR>")
-- MOVEMENT:
-- Create nvim panes:
vim.keymap.set('n', '<Leader>v', '<Cmd>wincmd v<CR>')
vim.keymap.set('n', '<Leader>s', '<Cmd>wincmd s<CR>')
-- Create tmux panes:
vim.keymap.set('n', '<Leader>tv', "<Cmd>lua require('windex').create_pane('vertical')<CR>")
vim.keymap.set('n', '<Leader>ts', "<Cmd>lua require('windex').create_pane('horizontal')<CR>")
Use the tabpage-scoped variable vim.t.maximized
to check whether the current window
is maximized or not.
local function maximize_status()
return vim.t.maximized and ' ' or ''
end
require('lualine').setup {
sections = {
lualine_c = { maximize_status }
}
}
-- ~/.config/nvim/lua/winbar.lua
local M = {}
M.maximize_status = function()
return vim.t.maximized and ' ' or ''
end
return M
-- ~/.config/nvim/init.lua
vim.o.winbar = "%{%v:lua.require('winbar').maximize_status()%}"
Note: Check the default keymaps on how to implement the functions in keymaps.
Maximize the current neovim window completely without any of the ugly borders that other plugins create.
require('windex').toggle_nvim_maximize()
Maximize the current neovim window AND tmux pane for when you need something completely fullscreen.
require('windex').toggle_maximize()
Toggle the (improved) interactive native terminal.
require('windex').toggle_terminal([{maximize} [, {command}]])
The {maximize} values are:
'none' - No maximizing,
'nvim' - Maximize the neovim window,
'all' - Maximize the neovim window and tmux pane (the default).
The optional {command} argument is a command to run in a non-interactive terminal.
Example: Custom keymap to open lazygit fullscreen.
vim.api.nvim_set_keymap(
'n',
'<C-g>',
"<Cmd>lua require('windex').toggle_terminal('all','lazygit')<CR>",
{ noremap = true, silent = true }
)
Treats tmux panes as neovim windows which allows for easy window/pane movement, with the same function. The {direction} values are: 'up', 'down', 'left' or 'right'.
require('windex').switch_window({direction})
Save and quit the neovim window, or kill the tmux pane, in the selected direction. The {direction} values are: 'up', 'down', 'left' or 'right'.
require('windex').close_window({direction})
Jump to the last neovim window or tmux pane.
require('windex').previous_window()
Create a tmux pane. The {split} values are: 'vertical' or 'horizontal'.
require('windex').create_pane({split})