mrjones2014 / smart-splits.nvim

🧠 Smart, seamless, directional navigation and resizing of Neovim + terminal multiplexer splits. Supports tmux, Wezterm, and Kitty. Think about splits in terms of "up/down/left/right".
MIT License
973 stars 43 forks source link

[Bug]: Windows navigation #94

Closed jeeeem closed 1 year ago

jeeeem commented 1 year ago

Similar Issues

Neovim Version

NVIM v0.9.0-dev-1355+gb2d10aa01

Multiplexer Integration

Wezterm

Multiplexer Version

wezterm 20230421-075330-e0a92c73

Steps to Reproduce

Same as https://github.com/wez/wezterm/issues/3597

Just wanna ask have you tried this in Windows environment?, cos I wanna know if this is just really a windows-centric issue.

Expected Behavior

Should be able to navigate smoothly like tmux integration with vim using ctrl+ keymap

Actual Behavior

It is working but have a weird behavior as it using different keymap rather the specified keymap option

Minimal Configuration to Reproduce

local root = vim.fn.fnamemodify('./.repro', ':p')

-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
  vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end

-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    '--single-branch',
    'https://github.com/folke/lazy.nvim.git',
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  -- do not remove the colorscheme! it makes testing nicer
  'folke/tokyonight.nvim',
  'mrjones2014/smart-splits.nvim',
  -- add any other pugins here
}

require('lazy').setup(plugins, {
  root = root .. '/plugins',
})

require('smart-splits').setup({
  -- add any options here
})

-- recommended mappings
-- resizing splits
-- these keymaps will also accept a range,
-- for example `10<A-h>` will `resize_left` by `(10 * config.default_amount)`
vim.keymap.set('n', '<A-h>', require('smart-splits').resize_left)
vim.keymap.set('n', '<A-j>', require('smart-splits').resize_down)
vim.keymap.set('n', '<A-k>', require('smart-splits').resize_up)
vim.keymap.set('n', '<A-l>', require('smart-splits').resize_right)
-- moving between splits
vim.keymap.set('n', '<C-h>', require('smart-splits').move_cursor_left)
vim.keymap.set('n', '<C-j>', require('smart-splits').move_cursor_down)
vim.keymap.set('n', '<C-k>', require('smart-splits').move_cursor_up)
vim.keymap.set('n', '<C-l>', require('smart-splits').move_cursor_right)
-- swapping buffers between windows
vim.keymap.set('n', '<leader><leader>h', require('smart-splits').swap_buf_left)
vim.keymap.set('n', '<leader><leader>j', require('smart-splits').swap_buf_down)
vim.keymap.set('n', '<leader><leader>k', require('smart-splits').swap_buf_up)
vim.keymap.set('n', '<leader><leader>l', require('smart-splits').swap_buf_right)

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme! it makes testing nicer
vim.cmd([[colorscheme tokyonight]])

Additional Details and/or Screenshots

No response

mrjones2014 commented 1 year ago

Just wanna ask have you tried this in Windows environment?

I haven't, I don't use Windows and don't have any Windows computers.

I assume this applies specifically to Wezterm, is that correct? Do other multiplexers work as intended on Windows?

Can you try, from a different terminal, run Wezterm via the CLI by running the command wezterm, then open Neovim (in the new Wezterm window you just opened) and run require('smart-splits).setup({ multiplexer_integration = 'wezterm' }) to ensure it's using Wezterm, then try again, does anything interesting show up in Wezterm's log output in the other terminal?

mrjones2014 commented 1 year ago

Also, are you able to move across Wezterm splits by themselves, just not when you add Neovim splits to the mix?

Aditeya commented 1 year ago

I updated my plugins today, and ran into this issue. I'm running Arch Linux. When I create a wezterm split and run vim in it, I can move to the other window split for a second. After a second tho I can't move from vim to another wezterm window. I can however move from normal window to vim.

mrjones2014 commented 1 year ago

Can you try what I mentioned before:

Can you try, from a different terminal, run Wezterm via the CLI by running the command wezterm, then open Neovim (in the new Wezterm window you just opened) and run require('smart-splits).setup({ multiplexer_integration = 'wezterm' }) to ensure it's using Wezterm, then try again, does anything interesting show up in Wezterm's log output in the other terminal?

And add a print statement in the Wezterm mappings in the is_vim function, to check this comment from the wezterm issue? if wezterm is not reporting the foreground process name properly, then the keymaps won't work properly.

Aditeya commented 1 year ago

Ok, So I tried the first thing & that works. In my Config I had set multiplexer_integration to Wezterm (instead of wezterm).

As for the is_vim function. that was working fine. It returns nvim.

mrjones2014 commented 1 year ago

So it’s working for you now?

Aditeya commented 1 year ago

Yes

jeeeem commented 1 year ago

@mrjones2014 Sorry for the late reply but I also print the is_vim function and this is what I got image

I also tried what other user say - https://github.com/wez/wezterm/issues/3597#issuecomment-1520220244, but it is still not working with this code

local function is_vim(pane)
  function test()
    return pane:get_title():find("~") ~= nil
  end
  print(pane:get_title())
  print(test())

  return pane:get_title():find("NVIM") ~= nil
end

I tried to navigate many times but its not letting me navigate to different wezterm panes as you can see in the image below. image Although it is true, it doesn't navigate me

SilverMira commented 1 year ago

Getting the same issue on windows, pane:get_foreground_process_name() simply is not getting nvim.exe as the process name, but one of its child process, in this case lua-language-server.exe as LSP was running, probably an upstream issue on Wezterm image

mrjones2014 commented 1 year ago

Should be resolved on latest master with some small config changes. See README.md