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.
- 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
qand 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
--choosefilespath 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
qdisturbs 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?