New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic line number toggle does not work inside tmux #45

Closed
jdhao opened this Issue Jan 10, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@jdhao
Copy link

jdhao commented Jan 10, 2019

I read your post here and the automatic number toggle works great. The settings I use:

augroup numbertoggle
  autocmd!
  autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
  autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber
augroup END

But it seems that this setting does not work inside tmux. If I open two tmux panes side by side and open a file with Neovim in one pane and then switch to another tmux pane, the relative line number in Neovim does not change to absolute number. How to fix this issue?

Besides, I use set -g mouse on inside ~/.tmux.conf so that I can use mouse to change tmux panes, if that information is relevant.

@jeffkreeftmeijer

This comment has been minimized.

Copy link
Owner

jeffkreeftmeijer commented Jan 10, 2019

That article includes a simplified version of the number toggling. This plugin is a little smarter, and it includes support for things like this since cfaecb9. Could you try installing the plugin, to see if that solves your issue? I'll make sure to add a note about this to the article.

@jdhao

This comment has been minimized.

Copy link
Author

jdhao commented Jan 10, 2019

I have installed this plugin. It does not work.

@jeffkreeftmeijer

This comment has been minimized.

Copy link
Owner

jeffkreeftmeijer commented Jan 10, 2019

I’m afraid I can’t reproduce this myself. I have set -g mouse on in my .tmux.conf, and toggling seems to work both when switching with the keyboard, and clicking the other pane with the mouse.

Could you make sure you have the most recent version of vim-numbertoggle installed, and have removed the code snippet from the article from your Vim configuration files?

@jdhao

This comment has been minimized.

Copy link
Author

jdhao commented Jan 11, 2019

Yes, I am using the latest version of vim-numbertoggle and have removed the the simpler code snippet.
You can in the following image, line number does not change when I switch to another tmux pane.
video_2019-01-11_143945

@jdhao

This comment has been minimized.

Copy link
Author

jdhao commented Jan 11, 2019

I have filed an issue on Neovim repo and got the right answer.

We need to turn on the focus-events for tmux. Edit the tmux config file ~/.tmux.conf and add the following setting:

set -g focus-events on

@jdhao jdhao closed this Jan 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment