kevinhwang91 / rnvimr

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

Opening files causes errors inside floating terminal. #111

Closed prdanelli closed 2 years ago

prdanelli commented 2 years ago

Firstly, I just wanted to say that your plugin is absolutely the best file navigation plugin i've used for Vim or Nvim, I used it every day when I was on linux and it was honestly amazing. I moved to MacOS and it seems to have issues around opening files, which is a huge bummer because no other file navigation plugin closed anywhere near as close to how nice RnVimr is to use.

I really hope this bug report helps to narrow down what might be causing the issue, because i'd love to be able to use it again.

Ranger

Python

Pynvim

Ueberzug (optional)

RPC

Describe the bug

When I try to open a file using Rnvimr, I see the following error messages, pressing q then opens the file inside of the floating terminal and requires :q to close the terminal:

nfo/mtime/sizemtime/humanreadablemtime/sizehumanreadablemtime
E1187: Failed to source defaults.vim
Error detected while processing /opt/homebrew/Cellar/neovim/0.7.0/share/nvim
/runtime/plugin/man.vim:
line    9:
E10: \ should be followed by /, ? or &
line   10:
E10: \ should be followed by /, ? or &
Error detected while processing /opt/homebrew/Cellar/neovim/0.7.0/share/nvim
/runtime/plugin/rplugin.vim[65]..function <SNR>10_LoadRemotePlugins[1]..<SNR
>10_GetManifest[1]..<SNR>10_GetManifestPath:
line    7:
E117: Unknown function: stdpath
--- Autocommands ---
Error detected while processing /opt/homebrew/Cellar/neovim/0.7.0/share/nvim
/runtime/plugin/shada.vim:
line    9:
E10: \ should be followed by /, ? or &
line   10:
E10: \ should be followed by /, ? or &
line   11:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   13:
E10: \ should be followed by /, ? or &
line   14:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   16:
E10: \ should be followed by /, ? or &
line   17:
E10: \ should be followed by /, ? or &
line   18:
E10: \ should be followed by /, ? or &
line   19:
E10: \ should be followed by /, ? or &
line   20:
E35: No previous regular expression
line   21:
E10: \ should be followed by /, ? or &
line   22:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   24:
E10: \ should be followed by /, ? or &
line   25:
E10: \ should be followed by /, ? or &
line   26:
E10: \ should be followed by /, ? or &
line   27:
E10: \ should be followed by /, ? or &
line   28:
E10: \ should be followed by /, ? or &
line   29:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   31:
E10: \ should be followed by /, ? or &
line   32:
E10: \ should be followed by /, ? or &
line   33:
E10: \ should be followed by /, ? or &
line   34:
E10: \ should be followed by /, ? or &
line   35:
E10: \ should be followed by /, ? or &
line   36:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   38:
E10: \ should be followed by /, ? or &
Press ENTER or type command to continue

To Reproduce using nvim -u mini.vim

Example:

This is a minimal init.lua file that was able to replicate the issue:

$ cat nvim/init.lua

local fn = vim.fn

-- Automatically install packer
local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
        PACKER_BOOTSTRAP = fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
        print "Installing packer close and reopen Neovim..."
        vim.cmd [[packadd packer.nvim]]
end

-- Use a protected call so we don"t error out on first use
local status_ok, packer = pcall(require, "packer")
if not status_ok then
        return
end

return packer.startup(function(use)
        -- Make packer manage itself
        use "wbthomason/packer.nvim"
        use "kevinhwang91/rnvimr"

        -----------------------------------------------------------------------------
        -- Automatically set up your configuration after cloning packer.nvim
        -- Put this at the end after all plugins
        -----------------------------------------------------------------------------
        if PACKER_BOOTSTRAP then
                require("packer").sync()
        end
end)

Steps to reproduce the behavior:

  1. run :RnvimrToggle
  2. Try to open a file

Expected behavior File should be opened in Nvim and the floating terminal closed

Screenshots If applicable, add screenshots to help explain your problem.

:RnvimrToggle

image

Opened init.lua:

image

Pressed Enter:

image

Pressed :q

image

q then closes the floating terminal

Additional context Add any other context about the problem here.

kevinhwang91 commented 2 years ago

Does this works for you? https://github.com/kevinhwang91/rnvimr/issues/11

prdanelli commented 2 years ago

@kevinhwang91 Thank you for replying so quickly.

For echo stdpath('data'), I get /Users/paul/.local/share/nvim.

I had installed ranger via pip3 install ranger-fm as suggested in the install guide.

ranger --version 

ranger version: ranger 1.9.3
Python version: 3.9.12 (main, Mar 26 2022, 15:44:31) [Clang 13.1.6 (clang-1316.0.21.2)]
Locale: en_GB.UTF-8

But the issue still persists. :(

kevinhwang91 commented 2 years ago

I can't reproduce the issue. Please try nvim -u NONE -i NONE mini.lua +'so', and open a file. cat mini.lua

vim.cmd('pa rnvimr')
vim.defer_fn(function()
    vim.cmd('RnvimrToggle')
end, 100)
prdanelli commented 2 years ago

@kevinhwang91 I created the mini.lua file wit the content you suggested.

When the file is executed by Nvim, Rnvimr opens on load:

image

When I try and open a file, I get the following:

image

The error seems to the same as before, however I cannot copy it because mouse interactions are disabled and any keypress closes the dialogue.

When I hit enter, the file is then opened within the terminal in what looks like an instance of Nvim.

image
kevinhwang91 commented 2 years ago

How about execute eval fm.client.rpc_edit(['mini.lua']) in Ranger command mode?

prdanelli commented 2 years ago

So, that seems to open the file:

From an empty buffer:

image

Inside the command mode:

image

Hit enter and the file is opened with the terminal window still open:

image
kevinhwang91 commented 2 years ago

But the buffer in normal window has been changed to mini.lua right?

prdanelli commented 2 years ago

That is correct. I closed mini.lua buffer initially to make it clear that the command you provided opened the file inside of the normal Nvim window, without causing the error.

Using the following, also opened the file inside a normal Nvim buffer without error:

eval fm.client.rpc_edit(['init.lua'])

image image
kevinhwang91 commented 2 years ago

You can also try eval fm.client.rpc_edit(['mini.lua'], 'edit')

update the mini.lua please, look like it's caused by your Ranger setup.

vim.cmd('pa rnvimr')
vim.g.rnvimr_vanilla = 1
vim.defer_fn(function()
    vim.cmd('RnvimrToggle')
end, 100)
kevinhwang91 commented 2 years ago

https://github.com/kevinhwang91/rnvimr#faq

prdanelli commented 2 years ago

You can also try eval fm.client.rpc_edit(['mini.lua'], 'edit')

update the mini.lua please, look like it's caused by your Ranger setup.

vim.cmd('pa rnvimr')
vim.g.rnvimr_vanilla = 1
vim.defer_fn(function()
    vim.cmd('RnvimrToggle')
end, 100)

I copied the commands into the mini.lua and they executed as the previous ones did, opening the file into a buffer whilst the terminal window stays open.

prdanelli commented 2 years ago

https://github.com/kevinhwang91/rnvimr#faq

I did follow that section of the FAQs and couldn't see any issues.

Pressing r inside of Rnvimr, gives me the following:

image

Edit:

This also seems the same:

echo $NVIM_LISTEN_ADDRESS

image

kevinhwang91 commented 2 years ago

You can also try eval fm.client.rpc_edit(['mini.lua'], 'edit') update the mini.lua please, look like it's caused by your Ranger setup.

vim.cmd('pa rnvimr')
vim.g.rnvimr_vanilla = 1
vim.defer_fn(function()
    vim.cmd('RnvimrToggle')
end, 100)

I copied the commands into the mini.lua and they executed as the previous ones did, opening the file into a buffer whilst the terminal window stays open.

vim.g.rnvimr_vanilla = 1 means skip your Ranger config, you should check out your Ranger config.

You can set rnvimr_vanilla to 1 in your normal config without mini.lua.

prdanelli commented 2 years ago

@kevinhwang91 Im so sorry for wasting your time. I'm not exactly sure what it is in my rifle.conf or rc.conf, but removing both files allows the files to be opened normally again.

Thank you for your time and thank you again for making such a useful plugin.

kevinhwang91 commented 2 years ago

Never mind