question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In netrw mode, three quits are required to close vim

See original GitHub issue
  • nvim --version: v0.8.0
  • Operating system/version: Linux archlinux 6.0.6-ach1-1
  • nvim +'checkhealth rnvimr':
rnvimr: health#rnvimr#check
========================================================================
## OS
  - OK: Name: Linux

## Ranger
  - OK: Version: ranger 1.9.3

## Python
  - OK: Version: 3.10.8 (main, Oct 13 2022, 21:13:48) [GCC 12.2.0]

## Pynvim
  - OK: Version: 0.4.3

## Ueberzug (optional)
  - OK: Ueberzug is ready

## RPC
  - OK: RPC echo: Neovim send "Give me five!" and receive "Give me five!"

Describe the bug
When ranger is used as a netrw replacement it does not immediately quit on q/:q. The first q/:q causes the screen to flash once. The second one will close ranger and the last :q is required to close vim.

To Reproduce using nvim -u mini.lua

Example: cat mini.lua

-- use your plugin manager, here is `packer`
require("packer").startup(function(use)

        use 'wbthomason/packer.nvim'

        use {
                "kevinhwang91/rnvimr",
                config = function()
                        vim.g.rnvimr_enable_ex = true
                end
        }

end)

Steps to reproduce the behavior:

  1. Install rnvmr
  2. Enable netrw replacement: vim.g.rnvimr_enable_ex = true
  3. Open vim with vim .
  4. Press q or :q (screen flashes once)
  5. Press q or :q again (ranger is closed, empty vim buffer is visible now)
  6. Exit vim :q

Expected behavior
Ranger and vim should close after pressing q or :q once (in netrw replacement mode).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinhwang91commented, Nov 11, 2022
vim.api.nvim_create_autocmd('VimEnter', {
    pattern = '*',
    once = true,
    callback = function()
        local name = vim.api.nvim_buf_get_name(0)
        if vim.fn.isdirectory(name) == 1 then
            vim.api.nvim_create_autocmd('FileType', {
                pattern = 'rnvimr',
                once = true,
                callback = function()
                    vim.api.nvim_create_autocmd('WinLeave', {
                        buffer = 0,
                        once = true,
                        callback = function()
                            vim.schedule(function()
                                name = vim.api.nvim_buf_get_name(0)
                                local off = vim.api.nvim_buf_get_offset(0, 1)
                                if name == '' and off <= 0 then
                                    vim.cmd('q')
                                end
                            end)
                        end
                    })
                end
            })
        end
    end
})

look redundant, but work fine.

0reactions
Nimmidevcommented, Nov 11, 2022

Works like a charm. tyvm

Read more comments on GitHub >

github_iconTop Results From Across the Web

netrw - Cannot exit Vim even using q!
Per default, netrw leaves unmodified buffers open. ... This stands for "buffer delete" and will close the buffer you have open.
Read more >
Using Netrw, vim's builtin file explorer | Devlog
Let's begin our exploration by taking a quick look at it. We can do this if we try to open a directory using...
Read more >
Vim - Quit/Close Netrw without selecting any file - Stack Overflow
So far, I have to select the currently opened file from within Netrw if I want to get back to it, which happens...
Read more >
Exiting the file explorer in vim - Ask Ubuntu
I typed :q and it gave me a segmentation fault. What should be the correct way to exit the file explorer in vim?...
Read more >
Closing netrw when selecting a file : r/vim - Reddit
It closes vim completely when selecting to traverse up the directory tree, and if I navigate away from netrw without closing it Vim...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found