christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
MIT License
5.07k stars 319 forks source link

Move from nvim to tmux pane not working. #370

Closed gyang274 closed 6 months ago

gyang274 commented 6 months ago

Hi Christoomey and team,

Thank you for this great tool.

After install following the guide, moving from nvim to tmux pane not working. Attached a screenshot of the output of :TmuxNavigatorProcessList in nvim.

Screenshot from 2023-12-12 20-27-58

My system: ubuntu 22.04 tmux 3.2a nvim v0.9.4

My ~/.config/tmux/tmux.conf

# Set true color 
set-option -sa terminal-overrides ",xterm*:Tc"

# Set prefix to ctrl + space
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix

# Set mouse on
set -g mouse on

# List of key bindings
bind -n M-H previous-window
bind -n M-L next-window

# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'catppuccin/tmux'

# Restore prefix + Ctrl-l to clear screen
bind C-l send-keys 'C-l'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

My ~/.config/nvim/lua/custom/init.lua

---@type ChadrcConfig
local M = {}

M.ui = { theme = 'catppuccin' }

M.plugins = 'custom.plugins'

return M

My ~/.config/nvim/lua/custom/plugins.lua

local plugins = {
  'christoomey/vim-tmux-navigator',
  lazy = false,
}

return plugins
MaxThom commented 6 months ago
image

Same for me, from Tmux side is working but not from neovim side. I'm using the lazy.kickstarter file for my setup.

this is my config.

return {
  'christoomey/vim-tmux-navigator',
  lazy = false,
  event = "BufReadPre",
}

I have noticed the plugin is at Start state. not sure what it means. waiting to be started?

image
fathineos commented 6 months ago

I added the following keymaps that solved the issue:

vim.api.nvim_set_keymap('n', '<C-l>', ':TmuxNavigateRight<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-j>', ':TmuxNavigateDown<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-h>', ':TmuxNavigateLeft<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-k>', ':TmuxNavigateUp<CR>', { noremap = true, silent = true })
MaxThom commented 6 months ago

worked for me! just had to run :luafile % for the keymaps to reload

christoomey commented 6 months ago

My sense is that kickstart or something else in your Vim config is overriding the keybindings, thus it doesn't work when you open nvim fresh, but does after resourcing the relavent config file. This also matches the output in the screenshot you shared for the <C-h> etc keybindings.

You might be able to chase down the conflicting key bindings w/ :verbose nmap <C-j> or similar (this should list where they were set).

Ultimately I think this is a case of conflicting configuration rather than an issue with the plugin, so I'm going to close this issue, but please feel free to comment if you think I've missed something.