nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.78k stars 833 forks source link

How To: replace netrw file explorer with file_browser #892

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello,

I've been playing around with the neovim nightly for 2 days and I discovered Telescope. I'm wondering if it's possible to replace the simple file browsing capabilities of netrw with builtins.file_browser. I tried to do the following, inspired from ranger.vim.

And after substitutions I got the following patch in my init.vim.

augroup ReplaceNetrw
    autocmd VimEnter * silent! autocmd! FileExplorer
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | Telescope file_browser({argv()[0]}) | endif
augroup END

When I do nvim documents/ I get a strange bunch of errors that I don't know how to begin debugging. Is there a quick fix for this, or is this still uncharted territory?

Conni2461 commented 3 years ago

Excuse my viml ignorance but this should work, might not be optimal:

augroup ReplaceNetrw
    autocmd VimEnter * silent! autocmd! FileExplorer
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | call luaeval("require('telescope.builtin').file_browser({cwd = _A})", argv()[0]) | endif
augroup END