Nvim-tree.lua: Not disable netrw

Created on 21 Jun 2020  路  9Comments  路  Source: kyazdani42/nvim-tree.lua

Is there a reason why netrw is being disabled? gx doesn't work without it in other buffers.

https://github.com/kyazdani42/nvim-tree.lua/blob/3bcfc70ea6759f40cc12e31e20f8b6c36f9ed2ac/plugin/tree.vim#L6-L7

Most helpful comment

Here's a mapping that will load netrw only on demand when using gx:

nnoremap gx :call <sid>open_url()<CR>

function! s:open_url() abort
  unlet! g:loaded_netrw
  unlet! g:loaded_netrwPlugin
  runtime! plugin/netrwPlugin.vim
  return netrw#BrowseX(expand('<cfile>'), netrw#CheckIfRemote())
endfunction

All 9 comments

well netrw opens automatically and it can conflict with other trees. I'll try and see if i can come up with a solution.

Well i'm sorry but i cannot enable the netrw, i don't really use the gx option, if you really want to use it in other buffers, feel free to implement it :) I have to disable netrw because i really have no use for it and its conflicting a lot with my workflow

Can we at least have an option for it? And btw, I'm writing a plugin to replace gx https://github.com/stsewd/gx-extended.vim if someone hits this, you can just install that plugin and gx should work just as the original gx in most cases.

if you do not disable netrw then it will open every time you do vim $DIR which will not be convenient at all. What would be your use cases to keep netrw ?

Mainly just to keep the original gx working. I don't use vim $DIR, so I'm fine if that doesn't work when enabling netrw.

well you can patch it locally if you want, but it seems weird to me that a tree viewer provides that kind of feature anyway. You could provide a global mapper with your gx plugin and not depend on the gx behaviour of netrw which would seem more adapted imo.

My plugin already maps gx globally, so I shouldn't need the original gx in most cases. But I think this should be mentioned in the docs at least, so users don't get a surprise when trying to use gx outside the tree.

i'll add that then :)

Here's a mapping that will load netrw only on demand when using gx:

nnoremap gx :call <sid>open_url()<CR>

function! s:open_url() abort
  unlet! g:loaded_netrw
  unlet! g:loaded_netrwPlugin
  runtime! plugin/netrwPlugin.vim
  return netrw#BrowseX(expand('<cfile>'), netrw#CheckIfRemote())
endfunction
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ziulev picture ziulev  路  8Comments

DimitrisMilonopoulos picture DimitrisMilonopoulos  路  5Comments

ahmedkhalf picture ahmedkhalf  路  7Comments

cloggier picture cloggier  路  8Comments

gmr458 picture gmr458  路  6Comments