1

I am trying to get ranger working inside neovim in a sensible way.

The official vim plugin provided by ranger works perfectly in ordinary vim: <Leader>r launches ranger in full screen, q exits ranger without changing the opened buffers, and it respects tabs and windows. However, when I try to use it with neovim, ranger fails to even launch.

This plugin from the neovim related projects works... somewhat. After evaluating :edit ., ranger launches in full screen, but there are several problems:

  • Before ranger becomes interactive, you have to enter insert mode.
  • It displays the vim line numbers (if enabled), which is ugly.
  • When you open a file or exit ranger with q, you're greeted with a terminal with [Process exited 0] which you must dismiss every time.
  • It doesn't respect your windows or tabs at all. I experimented with various combinations of windows and tabs and exiting ranger either by opening a file or with q and couldn't see any rhyme or reason as to what state your windows and tabs would be in afterward.

Finally I tried and got the furthest with this plugin, of which the previous plugin is a fork. Again, you launch ranger with :edit ., but it is immediately interactive without needing to enter insert mode, which is nice. It also respects tabs and windows. I swear I had to let g:ranger_open_mode = 'edit' to get that to work, but I have it set to tabe (the default) right now and it seems to be working. There are still some problems:

  • It also displays the undesired vim line numbers while ranger is active.
  • It does not launch ranger in full screen, but inside whatever window it was launched from.
  • Whenever you launch ranger, it launches in a buffer with a name like "term://.//24736:ranger --choosefiles=/tmp/nvimLMWwKJ/2 '/path/to/current/working/directory'". Each subsequent time ranger is launched, the integer at the end of the --choosefiles path is incremented. This name is visible while ranger is launched (ugly), but once a file is opened the buffer is made hidden and unmodifiable and its contents are changed to [Process exited 0]. It's annoying that these buffers are created and not cleaned up every time ranger is launched, but the worst part is that when ranger is exited using q, rather than returning the window to whatever buffer it previously had displayed, it displays the alternate buffer, which is one of these annoying terminals buffers.

I've tried several things to fix this last deficiency to no avail. Some close misses:

  • let g:ranger_on_exit = 'bw!' causes ranger to launch in the current window, but closes that window when you exit ranger and displays the new file (if any) in the window displaying the alternate buffer.
  • let g:ranger_on_exit = 'bnext' seems to work as intended when opening a file with ranger, but exiting ranger q disturbs the active window undesirably.

Any ideas on how to either get the first plugin working in neovim or getting one of the other plugins to replicate its functionality?

  • You may have some luck filing issues with the plugins if they're still being actively developed. In the meantime, I highly recommend becoming proficient with basic navigation in netrw; it does what you want it to do most of the time, and ships with vim. – D. Ben Knoble Dec 18 '18 at 0:36
0

https://github.com/ipod825/vim-netranger works pretty well in my opinion. I open it with vsplit.

The numbering can be removed. The fact it is a vim window is just an advantage.

The real problem is highlighting that only works in the original neovim in the terminal. It can be solved. Let me know if you have done it.

  • Undoubtedly, it is the best integration. The author solved the issue with the highlighting. – eyal karni Jun 15 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.