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
895 stars 37 forks source link

[Bug]: After splitting the window in kitty, open nvim on both sides and use require('smart-splits').move_cursor_right which is invalid. #140

Closed kola-web closed 8 months ago

kola-web commented 9 months ago

Similar Issues

Neovim Version

NVIM v0.9.4 Build type: Release LuaJIT 2.1.1700008891

 系统 vimrc 文件: "$VIM/sysinit.vim"
     $VIM 预设值: "/opt/homebrew/Cellar/neovim/0.9.4/share/nvim"

Run :checkhealth for more info

Multiplexer Integration

Kitty

Multiplexer Version

kitty 0.31.0 created by Kovid Goyal

Steps to Reproduce

  1. Create vertical split
  2. Adjust size of split
  3. ...
  4. Profit?

Expected Behavior

Able to jump normally

Actual Behavior

No response

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

image image

mrjones2014 commented 9 months ago

Sorry, I'm not clear on what the actual issue is. Can you elaborate?

kola-web commented 8 months ago

image

@mrjones2014 When in the layout as shown in the figure, calling the require('smart-splits').move_cursor_right method on the left cannot jump to the right.

mrjones2014 commented 8 months ago

Is there anything relevant in :SmartSplitsLog?

kola-web commented 8 months ago

[五 12/15 18:01:10 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 18:01:45 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 18:03:32 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 18:09:08 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 18:13:25 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 18:16:57 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 18:19:37 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [Fri Dec 15 18:57:36 2023][smart-splits.nvim] Auto-detected multiplexer back-end: none [五 12/15 19:22:21 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 19:22:21 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 19:24:09 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 19:26:24 2023][smart-splits.nvim] Auto-detected multiplexer back-end: tmux [五 12/15 20:13:17 2023][smart-splits.nvim] Auto-detected multiplexer back-end: none

mrjones2014 commented 8 months ago

Wait, are you using tmux or kitty's multiplexer? It looks like auto-detection is detecting tmux instead of kitty.

You can try explicitly setting kitty as your mux in config:

require('smart-splits').setup({
  multiplexer_integration = 'kitty',
})
kola-web commented 8 months ago

[五 12/15 20:18:38 2023][smart-splits.nvim] Auto-detected multiplexer back-end: none [五 12/15 20:19:05 2023][smart-splits.nvim] Auto-detected multiplexer back-end: none No way Having tmux should be used for me in other terminals

mrjones2014 commented 8 months ago

this is solvable in user config:

require('smart-splits').setup({
  multiplexer_integration = vim.env.KITTY_LISTEN_ON ~= nil and 'kitty' or nil,
})

This will make it force kitty in Kitty terminal, or fall back to auto-detection in other terminals.

kola-web commented 8 months ago

image I modified the configuration like this, but it doesn't take effect

kola-web commented 8 months ago

@mrjones2014 Thank you for your help, thank you

mrjones2014 commented 8 months ago

Ah so its working now?

kola-web commented 8 months ago

no

mrjones2014 commented 8 months ago

What's the output from :lua=require('smart-splits.mux.kitty').is_in_session()?

Are you sure you followed all the setup instructions for kitty? It requires that you run with

# For linux only:
kitty -o allow_remote_control=yes --single-instance --listen-on unix:@mykitty

# Other unix systems:
kitty -o allow_remote_control=yes --single-instance --listen-on unix:/tmp/mykitty

Or have this in ~/.config/kitty/kitty.conf

# For linux only:
allow_remote_control yes
listen_on unix:@mykitty

# Other unix systems:
allow_remote_control yes
listen_on unix:/tmp/mykitty
kola-web commented 8 months ago

Other unix systems:

kitty -o allow_remote_control=yes --single-instance --listen-on unix:/tmp/mykitty

After executing this command, it is feasible in a newly opened window.

Other unix systems:

allow_remote_control yes listen_on unix:/tmp/mykitty

This command is not allowed