简体   繁体   English

nvim 使用 defx 而不是 NerdTree

[英]nvim use defx instead of NerdTree

I would like to open nvim with defx by default instead of Nerdtree.我想默认使用 defx 而不是 Nerdtree 打开 nvim。 Have no idea how to change that behaviour不知道如何改变这种行为

I am using defx and can open it through mapping with sf custom mapping command, but for that i should be already in nvim so it takes me two steps.我正在使用 defx 并且可以使用sf自定义映射命令通过映射打开它,但为此我应该已经在 nvim 中,所以我需要两个步骤。

vim 
sf

Sf lives in maps.vim Sf住在地图里。vim

" Description: Keymaps
" defx
nnoremap <silent>sf :<C-u>Defx -listed -resume
      \ -columns=indent:mark:icon:icons:filename:git:size
      \ -buffer-name=tab`tabpagenr()`
      \ `expand('%:p:h')` -search=`expand('%:p')`<CR>

Can i open defx with我可以打开defx吗

nvim .

I can disable nerdtree from opening in nvim/init.vim我可以禁止 nerdtree 在 nvim/init.vim 中打开

 " Disable netrw
 let g:loaded_netrwPlugin       = 1

but even with it I should do sf to open defx但即使有了它,我也应该做sf来打开 defx

so the answer from creator @Shougo was https://gitter.im/Shougo/defx.nvim?at=61abfda5b5ba9e5a11ef079e所以创建者@Shougo 的答案是https://gitter.im/Shougo/defx.nvim?at=61abfda5b5ba9e5a11ef079e

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM