2012-01-28
■[vim]unite.vim で候補ごとに default_action を設定する
先日書いた記事なんですが、コメントでやり方を教えていただいたので覚書。
kind で default_action を設定すれば出来るみたいです。
[unite-qfixlist]
let s:source = { \ "name" : "qfixhowm", \ "description" : "qfixhowm", \} function! s:source.gather_candidates(args, context) let list = qfixmemo#ListCmd() let new_memo = [{ \ "word" : "[ new memo ]", \ "default_action" : "new_memo", \ "kind" : "qfixlist_new_memo" \ }] return new_memo + map(list, '{ \ "word" : v:val.text, \ "kind" : "file", \ "action__path" : v:val.filename \ }') endfunction call unite#define_source(s:source) unlet s:source let s:kind = { \ "name" : "qfixlist_new_memo", \ "default_action" : "new_memo", \ "action_table" : { \ "new_memo" : { \ "is_selectable" : 0, \ } \ } \} function! s:kind.action_table.new_memo.func(candidates) tabnew call qfixmemo#EditNew() endfunction call unite#define_kind(s:kind) unlet s:kind " QFixList 側でウィンドウを出さないように設定 " g,a 等の呼び出し時にもウィンドウが出なくなるので注意 function! QFixListAltOpen(qflist, dir) return a:qflist endfunction let QFixListAltOpen = 1
これで [new memo] を選択した場合は new_memo-action が起動して、それ以外の場合は各々の action が起動します。
この考えはなかったなぁ…。
あと一瞬ウィンドウがでないやり方も教えていただいたので書いてみました。
トラックバック - http://d.hatena.ne.jp/osyo-manga/20120128/1327720005
リンク元
- 4 http://t.co/dSx0ucCf
- 3 http://atnd.org/events/21925
- 3 http://t.co/a2QpCjQf
- 3 http://www.google.co.jp/search?hl=ja&client=opera&hs=lbZ&rls=ja&channel=suggest&sa=X&ei=4UokT7PYN8GhiAfmkYnLBA&ved=0CBwQBSgA&q=c+++neocomplcache&spell=1&biw=1916&bih=972
- 2 http://a.hatena.ne.jp/spinor/
- 2 http://d.hatena.ne.jp/
- 2 http://reader.livedoor.com/reader/
- 2 http://rohinomiya.posterous.com/?tag=setting
- 2 http://search.yahoo.co.jp/search?p=C+++ベクトル型&search.x=1&fr=top_ga1_sa&tid=top_ga1_sa&ei=UTF-8&aq=&oq=
- 2 http://www.bing.com/search?q=vim-ref+c++&qs=n&form=QBRE&pq=vim-ref%20c%2B%2B&sc=0-0&sp=-1&sk=