Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sbeyer opened this issue Nov 25, 2021 · 7 comments

Comments

@sbeyer
Copy link

sbeyer commented Nov 25, 2021

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

@Murderlon
Copy link

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

@sbeyer
Copy link
Author

sbeyer commented Jan 26, 2022

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

@Murderlon
Copy link

Murderlon commented Jan 27, 2022

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
Copy link

Disabling netrw in your config should do the trick:

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

@sbeyer
Copy link
Author

sbeyer commented Feb 16, 2022

@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
Copy link
Owner

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

@abhinav
Copy link

abhinav commented Nov 5, 2022

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.

jwoudenberg added a commit to jwoudenberg/nix that referenced this issue Dec 23, 2023
This ensures that I get dirvish as a file browser when I open vim on a
directory path. See:
justinmk/vim-dirvish#213 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants