Closed aziz76 closed 1 year ago
Just to confirm, do you have the vim plugin installed? (https://github.com/christoomey/vim-tmux-navigator#vim)
Likewise, can you check the Vim key mappings per https://github.com/christoomey/vim-tmux-navigator#vim---tmux-doesnt-work?
Yes I have the vim-tmux-navigator plugin installed and the mappings have been set too. Here are my plugins.lua and mappings.lua (I'm running nvchad):
local plugins = {
{
"christoomey/vim-tmux-navigator",
lazy = false,
},
{
"vim-crystal/vim-crystal",
ft = "crystal"
},
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end,
},
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"rust-analyzer",
},
},
}
}
return plugins
local M = {}
M.general = {
n = {
["<C-h>"] = { "<cmd> TmuxNavigationLeft<CR>", "window left" },
["<C-l>"] = { "<cmd> TmuxNavigationRight<CR>", "window right" },
["<C-j>"] = { "<cmd> TmuxNavigationDown<CR>", "window down" },
["<C-k>"] = { "<cmd> TmuxNavigationUp<CR>", "window up" },
}
}
Just to confirm as the mappings can be overriden by later config lines, can you check them as per https://github.com/christoomey/vim-tmux-navigator#vim---tmux-doesnt-work?
Yes I checked and I don’t think that is the case. In fact the key mappings are working within neovim. For example when nvim-tree is open I am able to switch between the editor and the nvim-tree using C-h, C-L. It’s only switching out of nvim that isn’t working.On 11 Jun 2023, at 8:04 PM, Chris Toomey @.***> wrote: Just to confirm as the mappings can be overriden by later config lines, can you check them as per https://github.com/christoomey/vim-tmux-navigator#vim---tmux-doesnt-work?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
TmuxNavigationLeft
This is almost the correct command. It should be TmuxNavigateLeft
, etc.
Good spot thanks. Unfortunately it didn't fix the issue.
I'm having the same issue. Also running nvchad and my plugin.lua and mappings.lua look the same as what aziz76 has. Also have the exact same behaviour as described by him above. I'm on Fedora 38.
Yes I checked and I don’t think that is the case. In fact the key mappings are working within neovim. For example when nvim-tree is open I am able to switch between the editor and the nvim-tree using C-h, C-L. It’s only switching out of nvim that isn’t working.
@aziz76 just to double check here, can you share the output of :verbose nmap <C-h>
? It's possible you have a mapping like nmap <C-h> <C-w>h
which would let navigation in Vim work, but would not allow for the vim<>tmux integration.
Hi Chris,
This is the output of : verbose nmap
n
On 4 Jul 2023, at 7:16 PM, Chris Toomey @.***> wrote:
Yes I checked and I don’t think that is the case. In fact the key mappings are working within neovim. For example when nvim-tree is open I am able to switch between the editor and the nvim-tree using C-h, C-L. It’s only switching out of nvim that isn’t working.
@aziz76 https://github.com/aziz76 just to double check here, can you share the output of :verbose nmap
? It's possible you have a mapping like nmap h which would let navigation in Vim work, but would not allow for the vim<>tmux integration. — Reply to this email directly, view it on GitHub https://github.com/christoomey/vim-tmux-navigator/issues/355#issuecomment-1620502663, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADLVADUWJTNPWGXUWJ2OJ3XOQ6WBANCNFSM6AAAAAAZBRVY6E. You are receiving this because you were mentioned.
Yup, looks like you've got a conflicting mapping somewhere else in your config -- you'll need to find those conflicting config lines and remove them to get things working. Going to close this issue now as it looks like the issue is in your config rather than the plugin.
@aziz76 Hey hello, just to know if you've fixed the issue in your config file. Because I was having the same issue from yesterday(I started setting up nvim with 'NV Chad' 1.5 days ago) , & I solved the problem in my config file few moments ago. Now I can seamlessly move from nvim to tmux and vice versa with shortcuts (<Ctrl+h>, <Ctrl+j>, <Ctrl+k> and <Ctrl+l>)
. Will be glad if I be able to help.
ref https://github.com/NvChad/NvChad/issues/1984
M.disabled = {
n = {
-- Disable to allow the plugin nvim-tmux-navigator to bind (see custom/plugins.lua)
["<C-h>"] = "",
["<C-l>"] = "",
["<C-j>"] = "",
["<C-k>"] = "",
}
}
Not sure I understand, do I put these lines in custom/mappings.lua or custom/plugins.lua? I couldn't find any conflicting bindings as I have not assigned them anywhere else?
@aziz76 I see you didn't return M at the last line in your mappings.lua file. and you can see the lines in my tmux.conf file below. If you find anything missing in your file you can add it there and see if starts to work. After adding those lines of Vim style pane selection
and Shift Alt Vim keys to swich windows
section, I can easily switch from nvim to tmux and vice versa using Ctrl+h or j or k or l
based on direction.
set-option -sa terminal-overrides ",xterm*:Tc"
set -g mouse on
# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Shift Alt vim keys to switch windows
bind -n M-H previous-window
bind -n M-L next-window
set -sg escape-time 1
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'```
Also make sure you have the line M.mappings = require "custom.mappings"
in your chadrc.lua file.
local M = {}
M.general = {
n = {
["<C-h>"] = { "<cmd> TmuxNavigateLeft<CR>", "window left" },
["<C-l>"] = { "<cmd> TmuxNavigateRight<CR>", "window right" },
["<C-j>"] = { "<cmd> TmuxNavigateDown<CR>", "window down" },
["<C-k>"] = { "<cmd> TmuxNavigateUp<CR>", "window up" },
}
}
return M
And keep your mappings.lua file same as above. After all of these configurations, your navigation from nvim to tmux and tmux to nvim should work.
I fixed it defining the custom keymappings as you can see here.
It seems TmuxNavigator can't find the tmux process because :TmuxNavigatorProcessList shows:
Switching works from tmux to nvim and within nvim but not nvim to tmux. Not sure if I am doing something wrong.
Would appreciate any help.