LoginSignup
1
0

More than 1 year has passed since last update.

やっとdduを設定できた

Last updated at Posted at 2022-04-02

概要

vimを使っているのであればご存じ Shougo/ddu.vim をやっと使えるようになったのでご報告

利用環境

 windows11
 nvimq 0.6.1
 dein.vim

参考資料

 新世代のUI 作成プラグイン ddu.vim

設定内容

まあ、よくわからない人は以下の内容をddu.tomlとしてロードすれば動くとは思うが、この内容を解析して分かったのがまあ、本日であるということだ。

[[plugins]]
repo = 'Shougo/ddu.vim'
hook_add = '''
call ddu#custom#patch_global({
    \   'ui': 'ff',
    \   'sources': [{'name': 'file_rec', 'params': {}},
    \      {'name': 'file'},
    \      {'name': 'colorscheme'},
    \      {'name': 'buffer'}],
    \   'sourceOptions': {
    \     '_': {
    \       'matchers': ['matcher_substring'],
    \     },
    \   },
    \   'kindOptions': {
    \     'file': {
    \       'defaultAction': 'open',
    \     },
    \     'colorscheme': {
    \       'defaultAction': 'set',
    \     },
    \   },
    \   'uiParams': {
    \      'ff': {
    \         'startFilter': v:false,
    \         'split': 'floating',
    \      },
    \   },
    \   'filterParams': {
    \      'matcher_substring': {
    \          'highlightMatched': 'Search',
    \      },
    \   },
    \ })

autocmd FileType ddu-ff call s:ddu_my_settings()
function! s:ddu_my_settings() abort
  nnoremap <buffer><silent> <CR>
        \ <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>
  nnoremap <buffer><silent> <Space>
        \ <Cmd>call ddu#ui#ff#do_action('toggleSelectItem')<CR>
  nnoremap <buffer><silent> i
        \ <Cmd>call ddu#ui#ff#do_action('openFilterWindow')<CR>
  nnoremap <buffer><silent> q
        \ <Cmd>call ddu#ui#ff#do_action('quit')<CR>
endfunction

autocmd FileType ddu-ff-filter call s:ddu_filter_my_settings()
function! s:ddu_filter_my_settings() abort
  inoremap <buffer><silent> <CR>
  \ <Esc><Cmd>close<CR>
  nnoremap <buffer><silent> <CR>
  \ <Cmd>close<CR>
  nnoremap <buffer><silent> q
  \ <Cmd>close<CR>
endfunction

nnoremap <silent> xdf :Ddu file<cr>
nnoremap <silent> xdb :Ddu buffer<cr>
nnoremap <silent> xdr :Ddu file_rec<cr>
nnoremap <silent> xdc :Ddu colorscheme<cr>
'''


[[plugins]]
repo='Shougo/ddu-ui-ff'
[[plugins]]
repo='Shougo/ddu-source-file_rec'
[[plugins]]
repo='Shougo/ddu-source-file'
[[plugins]]
repo='Shougo/ddu-filter-matcher_substring'
[[plugins]]
repo='Shougo/ddu-kind-file'
[[plugins]]
repo='Shougo/ddu-commands.vim'
[[plugins]]
repo='4513ECHO/ddu-source-colorscheme'
[[plugins]]
repo='shun/ddu-source-buffer'

分かった内容

概念とplugin

  • dduはui,source,kindという概念があるというのだが、uiとsourceしかわかっていない。
  • インストールしたpluginが上記の設定ファイルの文末にある8個である。
  • このうち、ddu-source-xxというのがsourceで、上の設定ファイルでは、file,file_rec,buffer,colorschemeを設定している。
  • これにddu-commands.vimをinstallしてあれば、:Ddu file というようなコマンドで動作させることができる。
  • ddu-file_recってのはリカーシブで配下のファイルを全部表示する。
  • ddu-ui-ffというのがuiでこれも差し替えることができる。

ddu-ui-ffの設定

  • ddu-uiの設定で重要なのが2つのautocmdである。
  • 最初の設定がffへのコマンド定義でcrで選択、spaceでトグル、iを入力するとフィルター画面を表示、qで終了を定義してある
  • 次のddu-ff-filterってのがフィルター画面上での定義である。

ddu#custom#patch_globalの内容

  • この辺は他の例でも大体同じようで、上記の設定は'uiParams'の'split': 'floating',が少し特殊だ。
  • これは普通は’horizontal’になっていると思う。'floating'はnvimのみで使える。
  • 画面の大きさなんかも、設定によって変更することができるだろう。

キーマッピング

nnoremapを読めば、xdfでfile,xdbでbuffer,xdrでfile_rec,xdcでcolorschemeにマッピングしてある。まあ、ここはお好きにどうぞというところか

1
0
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
1
0