ycdzj/win-mover.nvim

github github
split-and-window
stars 10
issues 0
subscribers 1
forks 1
CREATED

2024-12-10

UPDATED

7 days ago


win-mover.nvim

win-mover.nvim is a Neovim window mover that ignores side windows.

Demo

Features

  • Window Move Mode similar to WinShift.nvim
  • Ignore side windows (e.g. NvimTree) so they will not move
  • Simple implementation

Requirements

  • Neovim >= 0.8.0

Installation

Install it with your favorite plugin manager:

lazy

{
  'ycdzj/win-mover.nvim',
  lazy = false,
  opts = {}, -- configuration goes here
}

packer

use {
  'ycdzj/win-mover.nvim',
  config = function()
    local win_mover = require('win-mover')
    win_mover.setup({}) -- configuration goes here
  end,
}

vim-plug

  1. Add this to your config:
    Plug 'ycdzj/win-mover.nvim'
    
  2. Call require('win-mover').setup with your configuration before using this plugin.

Configuration

Defaults

{
  ignore = {
    enable = false,
    filetypes = {},
  },
  highlight = {
    color = '#2e3440',
    transparency = 60,
  },
  move_mode = {
    keymap = {},
  },
}

Example

This is an example configuration that:

  • Binds <leader>e for entering Move Mode.
  • h,j,k,l to move window in Move Mode.
  • q or <Esc> to quit Move Mode.
  • Ignores windows such as NvimTree, neo-tree, etc.
local win_mover = require('win-mover')
win_mover.setup({
  ignore = {
    enable = true,
    filetypes = { 'NvimTree', 'neo-tree', 'Outline', 'toggleterm' },
  },
  move_mode = {
    keymap = {
      h = win_mover.ops.move_left,
      j = win_mover.ops.move_down,
      k = win_mover.ops.move_up,
      l = win_mover.ops.move_right,

      H = win_mover.ops.move_far_left,
      J = win_mover.ops.move_far_down,
      K = win_mover.ops.move_far_up,
      L = win_mover.ops.move_far_right,

      q = win_mover.ops.quit,
      ['<Esc>'] = win_mover.ops.quit,
    },
  },
})
vim.keymap.set("n", "<leader>e", win_mover.enter_move_mode, { noremap = true, silent = true })

Commands

  • :WinMover

    Enter Window Move Mode

License

MIT License