kevinhwang91 / rnvimr

Make Ranger running in a floating window to communicate with Neovim via RPC
BSD 3-Clause "New" or "Revised" License
804 stars 17 forks source link

Opening file throws error when neovim is ran on a directory #91

Closed Hunter522 closed 3 years ago

Hunter522 commented 3 years ago

Ranger

Python

Pynvim

Ueberzug (optional)

RPC

When opening a directory with nvim, rnvimr will pop up. But when you try opening up a file when hidden = true rnvimr throws an error:

Error detected while processing function <lambda>14[1]..<SNR>72_defer_check_dir[3]..rnvimr#open[6]..rnvimr#toggle[13]..<SNR>72_reopen_win:
line    2:
E5555: API call: Invalid buffer id: 3
Press ENTER or type command to continue

To Reproduce using nvim -u mini.vim

Example: cat mini.vim

" use your plugin manager, here is `vim-plug`
call plug#begin('~/.config/nvim/plugged')
Plug 'kevinhwang91/rnvimr'
let g:rnvimr_vanilla = 1
let g:rnvimr_enable_ex = 1
let g:rnvimr_enable_picker = 1
set hidden 
tnoremap <silent> <M-i> <C-\><C-n>:RnvimrResize<CR>
nnoremap <silent> <M-o> :RnvimrToggle<CR>
tnoremap <silent> <M-o> <C-\><C-n>:RnvimrToggle<CR>
call plug#end()

Steps to reproduce the behavior:

  1. nvim -u mini.vim somedirectory
  2. Pick file from ranger popup
  3. Observe error

Expected behavior Ranger popup should close/hide when file is picked.

Additional context rnvimr seems to behave correctly with hidden = true as long as you dont start neovim on a directory. I've tested this with launching neovim with no arg, launching with file, and launching with session.

I set hidden because I want to use https://github.com/akinsho/nvim-toggleterm.lua. I'm sure hidden is useful to other for other reasons.

A workaround for me right now is to just run neovim with no args then toggle rnvimr and navigate to the directory I want.

kevinhwang91 commented 3 years ago

I have set hidden since I start to use neovim.

But I can't reproduce your issue, maybe mini.vim you provided is fake.

Check out whether the other file manager plugin wiped the buffer.

Hunter522 commented 3 years ago

You're right, I moved my ~/.local/share/nvim (I use paq-nvim) dir somewhere else, reinstalled vim-plug, launched neovim, ran PlugInstall, restarted neovim with the above mini.vim and it seems to work. Essentially clean neovim + vim-plug install. Must have been something weird lingering behind like using another plugin even though I was using the -u mini.vim cmd line arg.

kevinhwang91 commented 3 years ago

Please update the repo, I add double-check bufnr, will be silent now, but not sure whether work as expected.

wenjinnn commented 3 years ago

I have the same issue, and after a couple hour of research I find out this problem is related to netrw, add this to init.lua solved my problem let g:loaded_netrw = 1 let g:loaded_netrwPlugin = 1 just some variable to disable netrw, hope it work for you guys