【问题标题】:nvim use defx instead of NerdTreenvim 使用 defx 而不是 NerdTree
【发布时间】:2021-12-03 21:00:40
【问题描述】:

我想默认使用 defx 而不是 Nerdtree 打开 nvim。不知道如何改变这种行为

我正在使用 defx,可以通过 sf 自定义映射命令映射打开它,但为此我应该已经在 nvim 中,所以我需要两个步骤。

vim 
sf

Sf 存在于 maps.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>

我可以打开 defx 吗

nvim .

我可以禁止 nerdtree 在 nvim/init.vim 中打开

 " Disable netrw
 let g:loaded_netrwPlugin       = 1

但即使使用它我也应该执行 sf 来打开 defx

【问题讨论】:

  • 你能显示你的sf 映射吗?我没用这个插件,所以想看看触发它的命令。
  • nnoremap sf :Defx -listed -resume \ -columns=indent:mark:icon:icons:filename:git:size \ -buffer-name=tabtabpagenr() \ expand('%:p:h') -search=expand('%:p')

标签: plugins neovim nerdtree


【解决方案1】:

所以创作者@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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    • 2019-12-30
    • 2011-02-22
    相关资源
    最近更新 更多