vim-dirvish icon indicating copy to clipboard operation
vim-dirvish copied to clipboard

netrw instead of dirvish with nvim invocation on directory (could be plugin manager issue)

Open sbeyer opened this issue 2 years ago • 7 comments

Recently I observed the following behavior:

  • When I start neovim with a directory as argument, netrw shows up instead of dirvish,
  • In all other cases, dirvish works as expected.

I haven't yet taken the time to fully figure out what's going on but I changed a lot in my neovim configuration recently. Most importantly, I have switched from Plug to Paq and from Paq to Packer and it seems the problem is related. I am pretty sure it all worked when I used Plug and it stopped working with Paq and Packer. I have no special configuration for dirvish, just including the package (this hasn't changed in Plug/Paq/Packer).

I am using neovim 0.5.1

sbeyer avatar Nov 25 '21 00:11 sbeyer

Facing the same issue, did you find a solution @sbeyer ?

Murderlon avatar Jan 26 '22 21:01 Murderlon

No, I haven't currently looked into it further although it bothers me on a daily basis. Which package manager do you use?

sbeyer avatar Jan 26 '22 22:01 sbeyer

If you're in the lua ecosystem with packer and such, I recommend lir.nvim.

If you're going to try it, you can safe some time with this config, which took a bit of research for me. If you're getting a netrw error on start, you need to place the netrw settings somewhere where it's loaded first.

local actions = require'lir.actions'
local clipboard_actions = require'lir.clipboard.actions'
local map = vim.api.nvim_set_keymap

-- Disable netrw
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- Open lir like netrw with vinegar or dirvish
map( 'n', '-', [[<Cmd>execute 'e ' .. expand('%:p:h')<CR>]], { noremap = true })

require'lir'.setup {
  show_hidden_files = true,
  devicons_enable = true,
  float = { winblend = 0 }, -- keep float setting even if you don't use it, otherwise it will crash
  hide_cursor = false,
  mappings = {
    ["<CR>"] = actions.edit,
    ["-"] = actions.up,

    ['<C-s>'] = actions.split,
    ['<C-v>'] = actions.vsplit,
    ['<C-t>'] = actions.tabedit,

    ['q']     = actions.quit,

    ['d']     = actions.mkdir,
    ['N']     = actions.newfile,
    ['R']     = actions.rename,
    ['Y']     = actions.yank_path,
    ['.']     = actions.toggle_show_hidden,
    ['D']     = actions.delete,

    ['C'] = clipboard_actions.copy,
    ['X'] = clipboard_actions.cut,
    ['P'] = clipboard_actions.paste,
  },
}

Murderlon avatar Jan 27 '22 08:01 Murderlon

Disabling netrw in your config should do the trick:

-- Disable netrw
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

jonleopard avatar Feb 15 '22 23:02 jonleopard

@jonleopard Awesome! This works like a charm!

I don't know if this should be documented somewhere (maybe I just missed it)... if not, this issue can be closed.

edit: @Murderlon I missed those particular lines in your code snippet :/

sbeyer avatar Feb 16 '22 00:02 sbeyer

This might have been a Nvim packpath bug. With packer + Nvim 0.7.2 or later, can you confirm this is fixed?

justinmk avatar Jul 10 '22 00:07 justinmk

This might have been a Nvim packpath bug. With packer + Nvim 0.7.2 or later, can you confirm this is fixed?

FYI, nvim 0.8.0 + packer still has this issue. Still getting around it by disabling netrw.

abhinav avatar Nov 05 '22 20:11 abhinav