Shougo / defx.nvim

:file_folder: The dark powered file explorer implementation for neovim/Vim8
MIT License
1.17k stars 86 forks source link

How open Defx in the current directory with nvim . #296

Closed TeoDev1611 closed 3 years ago

TeoDev1611 commented 3 years ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

Hi How I open defx in the current directory when i run nvim . I try this but not work only open netrw

Expected

Open Defx in the current directory

Environment Information

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

https://pastebin.com/BJEcpJAq

Shougo commented 3 years ago
A: You can use autocmd for it.  But no official guarantee. Because it may
break other plugins behavior. >

    autocmd BufEnter,VimEnter,BufNew,BufWinEnter,BufRead,BufCreate
          \ * if isdirectory(expand('<amatch>'))
          \   | call s:browse_check(expand('<amatch>')) | endif

    function! s:browse_check(path) abort
      if bufnr('%') != expand('<abuf>')
        return
      endif

      " Disable netrw.
      augroup FileExplorer
        autocmd!
      augroup END

      execute 'Defx' a:path
    endfunction