justinmk / vim-dirvish

Directory viewer for Vim :zap:
Other
1.19k stars 64 forks source link

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

Open sbeyer opened 2 years ago

sbeyer commented 2 years ago

Recently I observed the following behavior:

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

Murderlon commented 2 years ago

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

sbeyer commented 2 years ago

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

Murderlon commented 2 years ago

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,
  },
}
jonleopard commented 2 years ago

Disabling netrw in your config should do the trick:

-- Disable netrw
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
sbeyer commented 2 years ago

@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 :/

justinmk commented 2 years ago

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

abhinav commented 1 year ago

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.