Giter Site home page Giter Site logo

nvim-tmux-navigation's Introduction

Neovim-Tmux Navigation

The plugin is a rewrite of Christoomey's Vim Tmux Navigator, with a few added benefits:

  • fully written in Lua, compatible with NeoVim 0.7.0 or higher
  • takes advantage of Lua closures
  • does not use global vim variables
  • switch to the next window (numerically), whether it is a neovim split or a tmux pane

The plugin does not, however, have a "save on switch" feature as Vim Tmux Navigator has, and does not work with tmate. For such features or any other, please open an issue or a pull request.

The plugin targets neovim 0.7.0 (for the keymap and user commands features) and more recent versions, and tmux 3.2a and more recent versions, although some of the older tmux versions should work as well.

Installation

To use the plugin, install it through a package manager, like vim-plug or lazy.nvim:

" vim-plug
Plug 'alexghergh/nvim-tmux-navigation'
" lazy.nvim
{ "alexghergh/nvim-tmux-navigation" }

Configuration

Before using the plugin, a few configuration steps are needed. Navigation keys need to be set up inside both tmux and neovim. Ideally, both should have the same navigation keys, so the transition between windows becomes transparent (it doesn't care if it's inside a vim process or not).

Tmux

The tmux part basically needs to know whether it is inside a vim process, and send the navigation keys through to it in that case. If it is not, then it just switches panes.

You need the lines below in your ~/.tmux.conf. This assumes that you want to use Ctrl keybinds to switch between windows, however feel free to switch to any other prefix (like Alt/Meta; for example M-h).

Careful though, having Ctrl as prefix means that you lose access to the "clear screen" terminal feature, activated by <Ctrl-l> by default. You can either:

  • remap the keys to something like Alt + h/j/k/l if your terminal supports it (not all do), or
  • add a different keybind to clear screen in ~/.tmux.conf, for example bind C-l send-keys 'C-l'; this allows you to do <prefix> C-l to clear screen.
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator

# decide whether we're in a Vim process
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'

tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'

if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+

Tmux Plugin Manager

Alternatively, the above is already implemented as a plugin in TPM (thanks to Chris Toomey). You just need to append the following lines to your plugins in your tmux.conf file (though keep in mind this Tmux plugin doesn't implement C-Space, as that's an nvim-tmux-navigation thing; if you need that, you have to add it manually):

set -g @plugin 'christoomey/vim-tmux-navigator'
run '~/.tmux/plugins/tpm/tpm'

Neovim

After you configured tmux, it's time to configure neovim as well.

To configure the keybinds, do (in your init.vim):

nnoremap <silent> <C-h> <Cmd>NvimTmuxNavigateLeft<CR>
nnoremap <silent> <C-j> <Cmd>NvimTmuxNavigateDown<CR>
nnoremap <silent> <C-k> <Cmd>NvimTmuxNavigateUp<CR>
nnoremap <silent> <C-l> <Cmd>NvimTmuxNavigateRight<CR>
nnoremap <silent> <C-\> <Cmd>NvimTmuxNavigateLastActive<CR>
nnoremap <silent> <C-Space> <Cmd>NvimTmuxNavigateNext<CR>

For init.lua, you can either map the commands manually (probably using vim.keymap.set), or you can keep on reading to find out how the plugin can do it for you!

There are additional settings for the plugin, for example disable navigation between tmux panes when the current pane is zoomed. To activate this option, just tell the plugin about it (inside the setup function):

require'nvim-tmux-navigation'.setup {
    disable_when_zoomed = true -- defaults to false
}

Additionally, if using lazy.nvim inside your init.lua, you can do everything at once:

{ 'alexghergh/nvim-tmux-navigation', config = function()

    local nvim_tmux_nav = require('nvim-tmux-navigation')

    nvim_tmux_nav.setup {
        disable_when_zoomed = true -- defaults to false
    }

    vim.keymap.set('n', "<C-h>", nvim_tmux_nav.NvimTmuxNavigateLeft)
    vim.keymap.set('n', "<C-j>", nvim_tmux_nav.NvimTmuxNavigateDown)
    vim.keymap.set('n', "<C-k>", nvim_tmux_nav.NvimTmuxNavigateUp)
    vim.keymap.set('n', "<C-l>", nvim_tmux_nav.NvimTmuxNavigateRight)
    vim.keymap.set('n', "<C-\\>", nvim_tmux_nav.NvimTmuxNavigateLastActive)
    vim.keymap.set('n', "<C-Space>", nvim_tmux_nav.NvimTmuxNavigateNext)

end
}

Or, for a shorter syntax:

{ 'alexghergh/nvim-tmux-navigation', config = function()
    require'nvim-tmux-navigation'.setup {
        disable_when_zoomed = true, -- defaults to false
        keybindings = {
            left = "<C-h>",
            down = "<C-j>",
            up = "<C-k>",
            right = "<C-l>",
            last_active = "<C-\\>",
            next = "<C-Space>",
        }
    }
end
}

The 2 snippets above are completely equivalent, however the first one gives you more room to play with (for example to call the functions in a different mapping, or if some condition is met, or to ignore silent in the keymappings, or to additionally call the functions in visual mode as well, etc.).

!NOTE: You need to call the setup function of the plugin at least once, even if empty:

{ 'alexghergh/nvim-tmux-navigation', config = function()
    require'nvim-tmux-navigation'.setup()
end
}

Usage

If you went through the Configuration, then congrats! You should have a working set up.

As a summary, the keybinds are (assuming Ctrl-prefixed):

  • Ctrl + h: move left
  • Ctrl + j: move down
  • Ctrl + k: move up
  • Ctrl + l: move right
  • Ctrl + \: move to the last (previously active) pane
  • Ctrl + Space move to the next pane (by pane number)

There are also convenience commands already implemented for you:

  • :NvimTmuxNavigateLeft
  • :NvimTmuxNavigateDown
  • :NvimTmuxNavigateUp
  • :NvimTmuxNavigateRight
  • :NvimTmuxNavigateLastActive
  • :NvimTmuxNavigateNext

Alternatives

As with everything that's great in life, there are a ton of alternatives to this plugin. These are great projects, born from the same desire to improve user experience within Tmux and Neovim. Go check them out and see if you like those more:

FAQ

  1. Q: The plugin doesn't work when using Fig. How can I fix it? A: Known problem, see this issue for a workaround fix.

  2. Q: There's noticeable slowdown when switching splits/panes. Any fixes for that? A: See this issue for a possible workaround using pgrep (this might fail to work in some cases though; if you do find such a case please open an issue).

  3. Q: The plugin doesn't work when interacting with Poetry shells. A: This happens because Poetry spawns sub-tty's, therefore messing with Tmux's detection of Vim processes (Tmux cannot see Neovim when run inside Poetry). Until I have time and motivation to work on a fix for this, please see this issue for a few workarounds suggested by the community.

Additional help

For common issues, see Vim-tmux navigator.

For other issues, feature-requests or problems, please open an issue on github.

Author

Alexandru Gherghescu ([email protected])

With great thanks to Chris Toomey, whose plugin I used for a long time before Neovim 0.5.0.

License

The project is licensed under the MIT license. See LICENSE for more information.

nvim-tmux-navigation's People

Contributors

alexghergh avatar kevinrambaud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nvim-tmux-navigation's Issues

[Feature request]: add commands

would be nice to have commands like TmuxNavigateLeft, TmuxNavigateRight and so on. neovim supports adding commands by vim.api.nvim_create_user_command

Control + "\" -- do not work by default

Good day!

I use with:

  • TMUX -- set -g @plugin 'christoomey/vim-tmux-navigator'
  • VIM -- Plug 'christoomey/vim-tmux-navigator'
  • NVIM -- Lasy: "alexghergh/nvim-tmux-navigation"

CTRL + [h,j,k,l] work well,
but "CTRL + " do not work with "alexghergh/nvim-tmux-navigation"
by default (with out custom mapping)
do not workin not with Tmux, not with out tmux [zsh only]

`rocks.nvim`

Hi,

Would you consider packaging this nvim plugin to LuaRocks?
That would allow rock users like me to easily install this package with :Rocks install nvim-tmux-navigation
The rocks.nvim team setup a github action that publishes packages to LuaRocks to make it easier.

not work from tmux to nvim

I am able to switch from nvim to tmux, but not from tmux to nvim. I have set the following:

is_vim="ps -o state= -o comm= -t '#{pane_tty}'
| grep -iqE '^[^TXZ ]+ +(\S+\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'

"not an editor command" for all NvimTmuxNavigate* Commands

I'm using Neovim 0.8.2, tmux 3.3a.

I installed the plugin with vim plugged

Plug 'alexghergh/nvim-tmux-navigation'

and added the remaps to my vimrc

nnoremap <silent> <C-h> <Cmd>NvimTmuxNavigateLeft<CR>
nnoremap <silent> <C-j> <Cmd>NvimTmuxNavigateDown<CR>
nnoremap <silent> <C-k> <Cmd>NvimTmuxNavigateUp<CR>
nnoremap <silent> <C-l> <Cmd>NvimTmuxNavigateRight<CR>
nnoremap <silent> <C-\> <Cmd>NvimTmuxNavigateLastActive<CR>
nnoremap <silent> <C-Space> <Cmd>NvimTmuxNavigateNext<CR>

but it's telling me that the commands aren't editor commands. However, I am able to get christoomey/vim-tmux-navigator working. I did a :PlugClean after switching over but I'm not sure exactly what I'm doing wrong.

tpm support

Thanks for making this wonderful nvim extention... I have been using for months now, and it is working flowlessly

I have noticed there is no tpm support for this plugin, vim-tmux-navigator has it and mentions it here...
https://github.com/christoomey/vim-tmux-navigator/tree/master#tpm

can you please add something like that to nvim-tmux-navigation also?

as code seems almost same, can i add vim-tmux-navigator in tpm instead of copy pasting that code....?

Change "previous" to "last active"

With the introduction of a "next pane" feature, one has to wonder what the meaning of "previous" is.

To stop any ambiguity from happening, "previous" should be changed to "last active" everywhere. "Last active" can only mean 1 thing (well, it can mean 2 things really, but one of them is a little exaggerated).

Can not navigate out of neovim using keymap but works using Cmdline?

I have copied the config from the README to .config/nvim/lua/plugins/nvim-tmux-navigator.lua

I am using LazyVim.

I can navigate

  • between split windows in neovim
  • between tmux panes
  • from tmux to neovim

Navigating from neovim to tmux does not work using <C-hjkl> but it works using NvimTmuxNavigate*.

How can I fix that?

faster window switching

Hello,

I noticed tmux switching was slow for me, which ended up the ps command in 'is_vim' was taking close to 400ms to return (theres something going on with my system but it normally returns around 170ms). In the process of figuring out why it was slow, I noticed pgrep is much faster for this (~50ms), and it made a big difference for me. This is not exactly the same as it doesn't look at the ^TXZ states like the other is_vim does, but it seems to be working for me and I figured I'd share.

is_vim="tty=#{pane_tty} ; pgrep -t \${tty#/dev/} 'g?(view|n?vim?x?)(diff)?$' >/dev/null 2>&1"

Problem with swtiching panes

I'm very new at all this linux stuff so please forgive my incompetence. The following is a screen shot of of my configs: The top is the tmux config, the bottom left is the neovim keybind settings and the bottom right is my init.lua for neovim.

secondary memory heirarchy

My issues is that I can switch between neovim panes created inside neovim itself using the default keybinds (<C-h/j/k/l>) and I can also switch to panes outside of neovim (bash, for example). However, once I do this (i.e focus on a pane outside of neovim), the keybinds no longer work and I have to use the default tmux keybinds i.e. those prefixed by and followed by the directional keys, to swith around panes. The extension's keybinds work again once I switch to a neovim pane.

In the screenshot above, the top and bottom panes are seperate tmux panes. While the two on the bottom are split via neovim. So I can move between the bottom two using <C-h/j/k/l>, but once I focus on the top, the keybinds stop working and I have to use Ctrl + b followed by the directional keys to go back to the bottom panes.

Not Working as Expected with Lazyvim

https://www.reddit.com/r/neovim/comments/14yer8w/neovimtmux_navigation_plugin_with_lazyvim_not/

Hi,

I am trying to install the plugin https://github.com/alexghergh/nvim-tmux-navigation so I can easily switch between Tmux panes and Neovim panes. I am using the default lazyvim installation plus the additions I have mentioned https://www.lazyvim.org/installation

Currently, I am able to use ctrl+hjkl to move between neovim panes using the current setup in a normal session without tmux.

BUT

During a tmux session, I am only able to move between the tmux panes and not to/between the neovim sessions.

So this implementation that I have seems to not be working on the tmux side since the NvimTmux commands are executing as expected. I was hoping I could be pointed in the right direction towards fixing this tmux issue.


lua/plugins/tmux.lua

return {
  "alexghergh/nvim-tmux-navigation",
  event = "VeryLazy",
  config = function()
    local nvim_tmux_nav = require("nvim-tmux-navigation")
    nvim_tmux_nav.setup({
      disable_when_zoomed = true,
      -- defaults to false
      keybindings = {
        left = "<C-h>",
        down = "<C-j>",
        up = "<C-k>",
        right = "<C-l>",
        last_active = "<C-\\>",
        next = "<C-Space>",
      },
    })
  end,
}
lua/config/keymap.lua

vim.keymap.set("n", "<C-h>", "<Cmd>NvimTmuxNavigateLeft<CR>", { silent = true })
vim.keymap.set("n", "<C-j>", "<Cmd>NvimTmuxNavigateDown<CR>", { silent = true })
vim.keymap.set("n", "<C-k>", "<Cmd>NvimTmuxNavigateUp<CR>", { silent = true })
vim.keymap.set("n", "<C-l>", "<Cmd>NvimTmuxNavigateRight<CR>", { silent = true })
vim.keymap.set("n", "<C-\\>", "<Cmd>NvimTmuxNavigateLastActive<CR>", { silent = true })
vim.keymap.set("n", "<C-Space>", "<Cmd>NvimTmuxNavigateNavigateNext<CR>", { silent = true })
~/.tmux.conf

set -g default-terminal "screen-256color"

set -g prefix C-a
unbind C-b
bind-key C-a send-prefix

unbind %
bind | split-window -h 

unbind '"'
bind - split-window -v

unbind r
bind r source-file ~/.tmux.conf

bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5
bind -r h resize-pane -L 5

bind -r m resize-pane -Z

set -g mouse on

set-window-option -g mode-keys vi

bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"

unbind -T copy-mode-vi MouseDragEnd1Pane # don't exit copy mode when dragging with mouse

# remove delay for exiting insert mode with ESC in Neovim
set -sg escape-time 10

# tpm plugin
set -g @plugin 'tmux-plugins/tpm'

# list of tmux plugins
# set -g @plugin 'christoomey/vim-tmux-navigator'
# THIS IS WHERE THE NEW CODE FOR NAVIGATION IS
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'

tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'

if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+


# END FANCY STUFF <---------

set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart
set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves sessions for you every 15 minutes

set -g @themepack 'powerline/default/cyan'

set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'

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

Prioritize Neovim pane over tmux pane

Hi!

I have 2 neovim splits on the right and 1 tmux pane on the left, and my cursor is on the far left. When I now use "C-l" (shortcut for nvim_tmux_nav.NvimTmuxNavigateRight), I would expect the cursor move to the second neovim split from the left, in the same tmux split. Instead it jumps to the right pane. What am I missing?

Screenshot 2023-06-12 at 10 42 52 AM

My config
`local nvim_tmux_nav = require('nvim-tmux-navigation')
local keymap = vim.keymap.set
local opts = { noremap = true, silent = true}

nvim_tmux_nav.setup{}

keymap('n', "", nvim_tmux_nav.NvimTmuxNavigateLeft)
keymap('n', "", nvim_tmux_nav.NvimTmuxNavigateDown)
keymap('n', "", nvim_tmux_nav.NvimTmuxNavigateUp)
keymap('n', "", nvim_tmux_nav.NvimTmuxNavigateRight)
keymap('n', "<C-\>", nvim_tmux_nav.NvimTmuxNavigateLastActive)
keymap('n', "", nvim_tmux_nav.NvimTmuxNavigateNext)
`

-- tmux use {'alexghergh/nvim-tmux-navigation', disable_when_zoomed = true -- defaults to false }

tmux.conf

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# for neovim
set -g @resurrect-strategy-nvim 'session'
set -g @plugin 'catppuccin/tmux'

# Shift Alt vim keys to switch windows
bind -n M-H previous-window
bind -n M-L next-window

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'

tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'

if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+'

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+
# enforce 256, if problematic disable
# set -g default-terminal "screen-256color"

# Enable mouse
set -g mouse on 

# Start numbering from 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1 
set-option -g renumber-windows on 

# Change prefix key to CTRL + SPACE
unbind C-b
set -g prefix C-Space 
bind C-Space send-prefix

# 24bit color - if terminal allows
set-option -sa terminal-overrides ",xterm:Tc"

# increase limit
set-option -g history-limit 10000

# renumber windows after closing intermediary ones
set-option -g renumber-windows on

# visual notification of activity in other windows
set-window-option -g monitor-activity on
set-option -g visual-activity on

# set color for status bar
set-option -g status-bg colour234
set-option -g status-fg yellow
set-option -g status-attr dim

# Current window bright red, inactive dim blue
set-window-option -g window-status-current-fg brightred
set-window-option -g window-status-current-bg colour234
set-window-option -g window-status-current-attr bright

set-window-option -g window-status-fg brightblue
set-window-option -g window-status-bg colour234
set-window-option -g window-status-attr dim

# show host name and IP address on left side of status bar
set-option -g status-left-length 70
set-option -g status-left "#[fg=brightgreen]:: #h #[fg=brightcyan]:: #(curl icanhazip.com) #[fg=brightyellow]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #[fg=red]#(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') "

# show session name, window & pane number, date and time on right side of
# status bar
set-option -g status-right-length 60
set-option -g status-right "#[fg=white]#S #I #P ::#[fg=yellow] %d %b %Y ::#[fg=green] %H:%M:%S ::"

run '~/.tmux/plugins/tpm/tpm'

PS: Great Plugin, thank you for that!

Plugin does not work when a python virtual env is activated

Setup

  • macOS 10.15
  • Alacritty 0.10.1
  • tmux 3.3a
  • nvim 0.7.0
  • nvim-tmux-navigation plugin commit 0a084d7

Workflow

I use pipenv to create a python virtual environment. All is good from the :checkhealth point of view. But if I don't source the venv before launching nvim the plugin is working nicely. If I source the venv before launching nvim the plugin stops working. Still, if I run a plugin command manually it works.

:checkhealth report when venv is sourced

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "$HOME/.local/pipx/venvs/python-lsp-server/bin/python"
  - INFO: Executable: /Users/azp/.local/pipx/venvs/python-lsp-server/bin/python
  - INFO: Python version: 3.10.5
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - WARNING: $VIRTUAL_ENV is set to: /Users/azp/.local/share/virtualenvs/tcs-Qsyv8aDE
    And its /bin directory contains: python, python3, python3.10
    But $PATH in subshells yields this python3 executable: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
    And $PATH in subshells yields this python3.10 executable: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
    So invoking Python may lead to unexpected results.
    - ADVICE:
      - $PATH ambiguities in subshells typically are caused by your shell config overriding the $PATH previously set by the virtualenv. Either prevent them from doing so, or use this workaround: https://vi.stackexchange.com/a/34996

Plugin works via the command line but not the keybinding

I'm using Alacritty / Fish / Tmux 3.3a / Nvim 0.7 on macOS 10.15.7

I can't manage to make this plugin work. If I insert :lua require'nvim-tmux-navigation'.NvimTmuxNavigateLeft() in the Nvim command it works fine but the keybinding is not responding. I made a gist of my relevant config files below :

Here is my plugin file : https://gist.github.com/AxZxP/660f21651674599432a7e4b1e2976a30

keymap : https://gist.github.com/AxZxP/2b90e9dcb67bacc53fdaebbcd75ffbab

tmux conf : https://gist.github.com/AxZxP/cadd70ea99a9de01140d1152c2f76f14

Update for Neovim 0.7.0

Following the release of Neovim 0.7.0, the keymap Lua API is improved. The code should change to reflect that.

Is it possible to switch windows with C-w <direction>?

Hi!

I like the default way vim/nvim have all window-related commands after like and so on. So I'd like to use the default bindings to move between nvim panes (<C-w (hjkl)>) to work with this plugin. This works on the neovim side, but I couldn't figure out a way to bind this keychord in tmux, although apparently it should work.

Can you provide an example for the tmux config that binds the pane switching to the default vim keybinds for it? Thanks!

Does not work when running Vim in a Poetry shell

nvim-tmux-navigation doesn't work at all if the neovim session is run after poetry shell. Would appreciate help debugging, if possible.

:checkhealth outside of poetry shell:

Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.18/libexec/pyenv
- pyenv: Root: /Users/g/.pyenv
- `g:python3_host_prog` is not set.  Searching for python3 in the environment.
- Executable: /Users/g/.pyenv/versions/3.10.11/bin/python3
- Python version: 3.10.11
- pynvim version: 0.4.3
- OK Latest pynvim is installed.

and inside poetry shell, the same except for a virtualenv error:

Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.18/libexec/pyenv
- pyenv: Root: /Users/g/.pyenv
- `g:python3_host_prog` is not set.  Searching for python3 in the environment.
- Executable: /Users/g/.pyenv/versions/3.10.11/bin/python3
- Python version: 3.10.11
- pynvim version: 0.4.3
- OK Latest pynvim is installed.

Python virtualenv ~
- WARNING $VIRTUAL_ENV is set to: /Users/g/Desktop/zeit/ml/.venv
  And its /bin directory contains: python, python3, python3.10, pythoni, pythoni1
  But $PATH yields this pythoni executable: Traceback (most recent call last):
  File "/Users/g/Desktop/zeit/ml/.venv/bin/pythoni", line 30, in <module>
  from pyrepl.python_reader import main
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/python_reader.py", line 25, in <module>
  from pyrepl.completing_reader import CompletingReader
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/completing_reader.py", line 22, in <module>
  from pyrepl import commands, reader
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/commands.py", line 376, in <module>
  from pyrepl import input
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/input.py", line 39, in <module>
  from trace import trace
  ImportError: cannot import name 'trace' from 'trace' (/Users/g/.pyenv/versions/3.10.11/lib/python3.10/trace.py)
  
  And $PATH in subshells yields this pythoni executable: Traceback (most recent call last):
  File "/Users/g/Desktop/zeit/ml/.venv/bin/pythoni", line 30, in <module>
  from pyrepl.python_reader import main
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/python_reader.py", line 25, in <module>
  from pyrepl.completing_reader import CompletingReader
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/completing_reader.py", line 22, in <module>
  from pyrepl import commands, reader
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/commands.py", line 376, in <module>
  from pyrepl import input
  File "/Users/g/Desktop/zeit/ml/.venv/lib/python3.10/site-packages/pyrepl/input.py", line 39, in <module>
  from trace import trace
  ImportError: cannot import name 'trace' from 'trace' (/Users/g/.pyenv/versions/3.10.11/lib/python3.10/trace.py)
  
  And $PATH yields this pythoni1 executable:   File "/Users/g/Desktop/zeit/ml/.venv/bin/pythoni1", line 16
  print 'Python', sys.version
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
  
  And $PATH in subshells yields this pythoni1 executable:   File "/Users/g/Desktop/zeit/ml/.venv/bin/pythoni1", line 16
  print 'Python', sys.version
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
  
  So invoking Python may lead to unexpected results.
  - ADVICE:
    - $PATH ambiguities arise if the virtualenv is not properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, check that invoking Python from the command line launches the correct one, then relaunch Nvim.
    - $PATH ambiguities in subshells typically are caused by your shell config overriding the $PATH previously set by the virtualenv. Either prevent them from doing so, or use this workaround: https://vi.stackexchange.com/a/34996

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.