:Unite file_rec で、テンプレートファイルを選択して挿入する
とりあえず、既存の処理でどこまで出来るのか!に挑戦してみました。
[vim]
" read let read = { \ 'is_selectable' : 1, \ } function! read.func(candidates)"{{{ for l:candidate in a:candidates call unite#util#smart_execute_command('read', l:candidate.action__path) endfor endfunction"}}} call unite#custom_action('file', 'read', read) unlet read " templatefiles " Unite から選択して、template file を挿入する " filetype のディレクトリから選択を行う let $TEMPLAETFILES=$HOME."/templatefiles" nnoremap <Space>utmp :call l:unite_templatefiles($TEMPLAETFILES)<CR> function! l:unite_templatefiles(dir) call unite#start(['file_rec'], { \'input' : a:dir.'/'.&filetype, \'default_action' : 'read' \}) endfunction
上記の処理だとテンプレートファイルのディレクトリは、$TEMPLAETFILES/{filetype} になります。
使用するテンプレートファイル選択すれば、現在のバッファに :read コマンドで挿入が行われます。
特に難しい事はしていないと思います。
まぁ『スニペット補完でいいじゃんか!』といわれればそれまでですが。
ってか、やっぱり、スニペット補完でやりたいですね。
neocomplcache を導入済みならプレースホルダぐらいはテンプレートファイル側でかけるっぽいです。(全ての機能を試した訳じゃないので怪しいですが。
eval は無理でした。
うーん、もうちょっと便利にしたい。
あとやっぱり、action をもっと汎用的にしたいでござるよ……。