dwm.vimで開くunite actionの追加

半年ぶりに書くネタができた。


【Vim】タイル型ウィンドウマネージャでタブいらず | blog.remora.cxを3日ほど使ってみたけど、これは便利だと思う。普通にファイルを開くだけならの後でuniteを使えばいい。タブ切り替えよりも断然楽。

しかし、Unite gtagsなどでabove, belowするとウインドウ分割が汚くなってしまうので、uniteの勉強がてらdwm.vimでウインドウ分割するアクションを追加してみた。
普通にウインドウ分割でファイルを開いてからDWM_Focus()を呼ぶだけのコードだが、期待通りの動きをしてくれた。

let s:action = {
      \ 'description' : 'new dwm',
      \ 'is_selectable' : 1,
      \ }
function! s:action.func(candidates)
  for l:candidate in a:candidates
    call unite#util#command_with_restore_cursor('rightbelow split')
    call unite#take_action('open', candidate)
    call DWM_Focus()
  endfor
endfunction
call unite#custom_action('openable', 'dwm_new', s:action)
unlet s:action

uniteは簡単に拡張できて便利!