5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

defx.nvimの導入

Last updated at Posted at 2020-01-09

defx.nvimを導入していきます。
環境は MacVim Custom Version 8.1.2234 (161) です。

導入は非常に簡単です。
私はminpacを使っているのでこんな感じ。

.vimrc
call minpac#add('Shougo/defx.nvim')
if !has('nvim')
  call minpac#add('roxma/nvim-yarp')
  call minpac#add('roxma/vim-hug-neovim-rpc')
endif

これだけです。簡単。
しかし、これだけだと動かないのでキーバインドを追加します。

基本的には公式のサンプルをコピペしました。

一部手癖などに合わせて調整して

.vimrc
" ディレクトリの場合は開く。それ以外はすでにあるウインドウで開く。
  nnoremap <silent><buffer><expr> <CR>
  \ defx#is_directory() ?
  \  defx#do_action('open_directory') :
  \  defx#do_action('multi', ['drop', 'quit'])

" vsplitで開いてdefxを閉じる
  nnoremap <silent><buffer><expr> E
  \ defx#do_action('multi', [['open', 'vsplit'], 'quit'])

" <C-w>で親階層に移動する
  nnoremap <silent><buffer><expr> <C-w>
  \ defx#do_action('cd', ['..'])

" <C-p>でカーソルを上移動する
  nnoremap <silent><buffer> <C-p> <UP>

あとは適当なキーバインドをつけて

.vimrc
" NERDTreeのように左に表示する。現在のファイルの階層を開く。
  nnoremap <silent><C-e> :<C-u>Defx -split=vertical -winwidth=40 -search=`expand('%:p')` -direction=topleft `expand('%:p:h')`<CR>

完成!簡単便利!

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?