diff --git a/plugin/commands.lua b/plugin/commands.lua index fef7fe3..83a0c8f 100644 --- a/plugin/commands.lua +++ b/plugin/commands.lua @@ -205,3 +205,19 @@ end, { range = true }) vim.api.nvim_create_user_command('DiagnosticToggle', function(_) vim.diagnostic.enable(not vim.diagnostic.is_enabled()) end, {}) + +-- :ResizeFixed acts like :resize but also fixes the window size so it stops +-- automatically changing when other windows reflow. Respects the :vertical +-- modifier, resizing and fixing the width instead of the height. +vim.api.nvim_create_user_command('ResizeFixed', function(opts) + local cmd = { cmd = 'resize', mods = opts.smods } + if opts.args ~= '' then + cmd.args = { opts.args } + end + vim.cmd(cmd) + if opts.smods.vertical then + vim.wo.winfixwidth = true + else + vim.wo.winfixheight = true + end +end, { nargs = '?' })