Home

Awesome

windex.nvim

đŸ§ŧ A neovim plugin for cleeean neovim window (and tmux pane) functions. đŸ§ŧ

Works with or without tmux!

✨ Features

Window Maximizing

Note: Please see maximize.nvim for using just the window maximizing feature.

Terminal Toggle

Cleaner Window Movement

Note: The {motion} keys by default are h, j, k and l, but can be replaced with the arrow keys. See 'Configuration' for details.

đŸ”Ĩ Demos

<details> <summary markdown="span">Maximizing Performance Comparison with Vim-Maximizer</summary> <!-- A comparison of vim-maximizer and windex.nvim with maximizing a nvim window and a tmux pane split. -->

vim-maximizer

Has weird thing in the top left where it didn't maximize properly and doesn't maximize the tmux pane. đŸ¤ĸ

vim-maximizer

windex.nvim

Perfectly maximizes the neovim window and tmux pane! 👑

windex

</details> <details> <summary markdown="span">Demo Video - Terminal Toggle</summary>

Window / Pane Movement and Terminal Toggle

https://user-images.githubusercontent.com/90937622/159681079-58f36668-e78b-41fa-b929-e9ebc9dd8d3b.mp4

</details>

đŸ“Ļ Installation

Install with your favourite plugin manager and run the setup function.

Note: I highly recommend using bufresize.nvim especially when using tmux.

Packer

use {
  'declancm/windex.nvim',
  config = function() require('windex').setup() end
}

⚙ī¸ Configuration

A settings table can be passed into the setup function for custom options.

Default Settings

-- 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.

Example Configuration

require('windex').setup {
  extra_keymaps = true,
  save_buffers = true,
}

⌨ī¸ Keymaps

Note: If the tmux requirement is not passed, the non-tmux keymaps will be used instead.

Default Keymaps

-- 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>")

Extra Keymaps

-- 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>")

đŸšĨ statusline & winbar

Use the tabpage-scoped variable vim.t.maximized to check whether the current window is maximized or not.

Lualine

local function maximize_status()
  return vim.t.maximized and 'ī‹ ' or ''
end

require('lualine').setup {
  sections = {
    lualine_c = { maximize_status }
  }
}

winbar

-- ~/.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()%}"

ℹī¸ API

Note: Check the default keymaps on how to implement the functions in keymaps.

Maximize Current Window

Terminal Toggle

Cleaner Window Movement