-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resizing (shrinking/growing) panes similarly to tmux.nvim
#25
Comments
Hi, This is how i solved this problem: -- Method do send keys to nvim from Navigator.nvim readme
local w = require 'wezterm'
local a = w.action
local function is_inside_vim(pane)
local tty = pane:get_tty_name()
if tty == nil then return false end
local success, stdout, stderr = w.run_child_process
{ 'sh', '-c',
'ps -o state= -o comm= -t' .. w.shell_quote_arg(tty) .. ' | ' ..
'grep -iqE \'^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$\'' }
return success
end
local function is_outside_vim(pane) return not is_inside_vim(pane) end
local function bind_if(cond, key, mods, action)
local function callback(win, pane)
if cond(pane) then
win:perform_action(action, pane)
else
win:perform_action(a.SendKey({ key = key, mods = mods }), pane)
end
end
return { key = key, mods = mods, action = w.action_callback(callback) }
end
-- My keys in config.keys
-- Move Between Panes With Navigator.nvim
bind_if(is_outside_vim, 'h', 'CTRL', a.ActivatePaneDirection('Left')),
bind_if(is_outside_vim, 'l', 'CTRL', a.ActivatePaneDirection('Right')),
bind_if(is_outside_vim, 'j', 'CTRL', a.ActivatePaneDirection('Down')),
bind_if(is_outside_vim, 'k', 'CTRL', a.ActivatePaneDirection('Up')),
-- Adjust Neovim And Wezterm Windows With Navigator.nvim
bind_if(is_outside_vim, 'h', 'CTRL|ALT', a.AdjustPaneSize { 'Left', 2 }),
bind_if(is_outside_vim, 'l', 'CTRL|ALT', a.AdjustPaneSize { 'Right', 2 }),
bind_if(is_outside_vim, 'k', 'CTRL|ALT', a.AdjustPaneSize { 'Up', 2 }),
bind_if(is_outside_vim, 'j', 'CTRL|ALT', a.AdjustPaneSize { 'Down', 2 }), Neovim mappings config local keymap = vim.keymap
-- Buffer Navigation
keymap.set('n', '<c-h>', '<CMD>NavigatorLeft<CR>', { desc = 'Move Split left' })
keymap.set('n', '<c-l>', '<CMD>NavigatorRight<CR>', { desc = 'Move Split right' })
keymap.set('n', '<c-j>', '<CMD>NavigatorDown<CR>', { desc = 'Move Split down' })
keymap.set('n', '<c-k>', '<CMD>NavigatorUp<CR>', { desc = 'Move Split up' })
keymap.set('n', '<a-c-h>', '<c-w>+', { desc = 'Adjust Split vertical+' })
keymap.set('n', '<a-c-l>', '<c-w>-', { desc = 'Adjust Split vertical-' })
keymap.set('n', '<a-c-k>', '<c-w>>', { desc = 'Adjust Split horizontal+' })
keymap.set('n', '<a-c-j>', '<c-w><', { desc = 'Adjust Split horizontal-' }) |
I just tried @Sombrer0Dev's suggestion, theres an oversight in this solution and that is when you have only nvim open in a wezterm pane, the resizing does not work because nvim think it should not do anything since its the only pane but also the binded key action in wezterm does not do anything either since its considered 'inside_vim', I tried to add another condition that checks to see if vim is occupying the whole pane, but I dont really know how to do it haha. |
The only thing I have been missing since I have moved from tmux.nvim is the ability to resize panes (between Neovim and my multiplexer) seamlessly like in the gif.
tmux-resize.mp4
Thank you for this awesome plugin (and Comment.nvim), been awesome getting to use Wezterm.
The text was updated successfully, but these errors were encountered: