最近の vimshell の変更で、今まで
デフォルトのアクションは execute で、履歴のコマンドを直接実行する。通常の補完のように挿入してから編集したい場合は insert アクションを実行すればいい。edit アクションや delete アクションで履歴の編集や削除もできる。
とまあ、こんな風に便利な機能なんだけど、逆に言うと unite をインストールしてない人は今まで使えたヒストリ補完は一切使えなくなる。また、ちょっとした履歴の表示/選択くらいなら unite じゃなくて今までの感じでやりたいって人もいるかもしれない。
てわけで、そういう人のために履歴を組み込み補完で表示する実装をでっち上げてみた。
" after/ftplugin/vimshell.vim function! s:complete_history() call complete(len(vimshell#get_prompt()) + 1, g:vimshell#hist_buffer) return '' endfunction inoremap <buffer> <silent> <C-l> <C-r>=<SID>complete_history()<CR><C-p>
こっちは iexe 版。
" vimrc augroup vimrc-plugin-vimshell autocmd! autocmd FileType int-* call s:init_vimshell_int() augroup END function! s:vimshell_complete_history() call complete(len(vimshell#get_prompt()) + 1, b:interactive.command_history) return '' endfunction function! s:init_vimshell_int() inoremap <buffer> <silent> <C-l> <C-r>=<SID>vimshell_complete_history()<CR><C-p> endfunction
まったく同じじゃないけど、今までと似た感じで使えると思う。ちなみに私は unite を主体に使おうと思いつつこっちの設定も未練がましく別のキーに割り当てて残してる。unite に完全に慣れたら消すかな。
ところで complete() はなんでデフォルトで空文字列返さないの? バカなの? 死ぬの?