ranger icon indicating copy to clipboard operation
ranger copied to clipboard

Files open in vim instead of nvim

Open letscho123 opened this issue 1 year ago • 6 comments

Runtime Environment

  • Operating system and version: Archlinux 6.6.1-arch1-1
  • Terminal emulator and version: kitty 0.30.1, fish 3.6.1
  • Python version: 3.11.5 (main, Sep 2 2023, 14:16:33) [GCC 13.2.1 20230801]
  • Ranger version/commit: ranger 1.9.3
  • Locale: en_US.UTF-8

Current Behavior

I start kitty with fish and then ranger. When I now open a textbased file (e.g. py) it opens in vim.

Expected Behavior

It should open in nvim

Context

The variables EDITOR and VISUAL are set to nvim in bash and in fish and the echo command shows that this is the case. Even if I open the shell inside ranger with "S", it shows nvim as editor. If I open ranger from bash, it opens files in nvim. If I switch to bash and then back to fish in the same terminal, also ranger in fish then opens files in nvim. Moreover, I use the Neovim plugin rnvimr, with which ranger works normal inside nvim.

In my rifle.conf: mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" If I change this to nvim it works, but then the Neovim plugin rnvimr doesn't work anymore.

I am using the exactly same configuration for kitty, fish and ranger on Fedora where I don't have this issue.

Steps to reproduce

  1. Open kitty with fish
  2. Open ranger
  3. Open .py file, which opens in vim

Traceback

No crash or error message.

letscho123 avatar Nov 14 '23 22:11 letscho123

What does echo $EDITOR output?

kohane27 avatar Nov 30 '23 01:11 kohane27

What does echo $EDITOR output?

nvim

Same result when I run this command in bash, fish or inside the ranger shell.

letscho123 avatar Nov 30 '23 07:11 letscho123

I think the relevant one is $VISUAL.

Edit: Sorry, just saw you already mentioned above that both EDITOR and VISUAL are set to nvim.

luator avatar Dec 07 '23 20:12 luator

I face the same problem when running ranger from a custom bind in i3 (exec alacritty -e ranger) or from dmenu (alacritty -e ranger). I have the same problem with alacritty or st.

There's no problem when running ranger myself from a terminal : (exec alacritty then $ ranger).

From those information :

  • the problem doesn't come from i3 nor dmenu since it happens from both
  • the problem doesn't come from alacritty nor st since it happens from both
  • the last option seems to be ranger but only when it's started as a command and not from a shell (st -e ranger, alacritty -e ranger)

It's really weird.

I don't know where to start from here.

qkzk avatar Feb 25 '24 20:02 qkzk

I had the same problem as @qkzk but with kitty. Solution that I found is that I should use .zshenv instead of .zshrc to set EDITOR and VISUAL. I think that when you start kitty from command you do not start interactive shell so .zshrc isn't loaded.

UPD: Just found out that my solution works only with sessions, at least with kitty. By the way I made it work at Fedora/Hyprland by defining ranger.conf at ~/.config/kitty like this:

new_tab ranger
title ranger
launch zsh -c 'ranger'

And then use this command for key binding: kitty --session ranger.conf

Have no idea why it works with sessions but does not work with kitty -e ranger. Maybe other zsh config files would work, but now I stick with it.

kekulta avatar Mar 17 '24 03:03 kekulta

I tried @kekulta solution and it doesn't work for me.

I also tried to force ranger to load its config from /home/qkzk/.config/ranger its datadir from /home/qkzk/.local/share/ranger with a script and it doesn't work either.

I'm stuck :/

qkzk avatar Mar 24 '24 07:03 qkzk