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

rnvimr is changing neovim's cwd when opening a file with `rnvimr_enable_picker` enabled #142

Closed brunobmello25 closed 1 year ago

brunobmello25 commented 1 year ago

Run :checkhealth for more info


- Operating system/version: Pop!_OS 22.04 LTS

- `nvim +'checkhealth rnvimr'`: 

rnvimr: health#rnvimr#check

OS ~

Ranger ~

Python ~

Pynvim ~

Ueberzug (optional) ~

RPC ~


**Describe the bug**
After selecting a file in ranger, cwd changes from the original directory where you opened neovim to the home directory.

**To Reproduce using `nvim -u mini.vim`**

Example:
`cat mini.vim`
```lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end

vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    'kevinhwang91/rnvimr',
    config = function()
      vim.keymap.set('n', '<leader>e', '<cmd>RnvimrToggle<cr>')
    end,
    init = function()
      vim.g.rnvimr_enable_picker = 1
    end
  }
})

Steps to reproduce the behavior (using /home/<user>/foo/bar as the example directory):

  1. open the directory with nvim . (should open in netrw)
  2. open a file
  3. run :lua print(vim.loop.cwd())
  4. see expected /home/<user>/foo/bar output
  5. press <space>e to open rnvimr (leader is mapped to space)
  6. open a file different from the one you opened previously
  7. run :lua print(vim.loop.cwd())
  8. see that it prints /home/<user> instead of the expected directory

Expected behavior Should maintain proper cwd instead of having this bug

Video reproducing this bug https://www.youtube.com/watch?v=dFPpnFkjCUc (apologies for the terrible pink background. This is related to my terminal colorscheme conflicting with neovim's defaullt colorscheme and shouldn't affect this issue)

Additional context Ranger version: 1.9.3 Python version: 3.10.6 Locale: en_US.UTF-8