cafegale(LeafCage備忘録)

LeafCage備忘録(はてなダイアリー)と統一しました。

vimrc読書会 30

shougoさんの

neobundleで遅延読み込みするには

> L110:sameってなんぞと思ったら、default optionが定義できるのか。>L100
そうです。

http://lingr.com/room/vim/archives/2013/01/26#message-13705598
"L100:
let g:neobundle#default_options = {
      \ 'same' : { 'stay_same' : 1, 'overwrite' : 0 },
      \ '_' : { 'overwrite' : 0 },
      \ }

"L110:
NeoBundleLazy 'tpope/vim-surround', '', 'same'

> L1268:neosnippetの設定で、let bundle = neobundle#get('neosnippet')してから
> function! bundle.hooks.on_source(bundle)
> していますがこれはどういうときに定義されるということですか
:NeoBundleSourceされたときに読み込まれます。

http://lingr.com/room/vim/archives/2013/01/26#message-13705928
let bundle = neobundle#get('neosnippet')
function! bundle.hooks.on_source(bundle)
  imap <silent>L     <Plug>(neosnippet_jump_or_expand)
  smap <silent>L     <Plug>(neosnippet_jump_or_expand)
  xmap <silent>L     <Plug>(neosnippet_start_unite_snippet_target)
...
  let g:neosnippet#enable_snipmate_compatibility = 1

  inoremap <expr><C-g>     neocomplcache#undo_completion()
  inoremap <expr><C-l>     neocomplcache#complete_common_string()

  " let g:snippets_dir = '~/.vim/snippets/,~/.vim/bundle/snipmate/snippets/'
endfunction

設定を on_source で書くのは良さそうだなーと思いつつ、lazy も設定してないとあまり意味ないか。

http://lingr.com/room/vim/archives/2013/01/26#message-13706965

on_source に書いておけば後から Lazy にする時に捗る。あと無効にする場合も

http://lingr.com/room/vim/archives/2013/01/26#message-13706976

ネオコン

L1158: ネオコンに専用補完を指定するのは便利そうですね
めんどくさがってこの辺の設定してないからなー

http://lingr.com/room/vim/archives/2013/01/26#message-13705811
  let g:neocomplcache_vim_completefuncs = {
        \ 'Ref' : 'ref#complete',
        \ 'Unite' : 'unite#complete_source',
        \ 'VimShellExecute' :
        \      'vimshell#vimshell_execute_complete',
        \ 'VimShellInteractive' :
        \      'vimshell#vimshell_execute_complete',
        \ 'VimShellTerminal' :
        \      'vimshell#vimshell_execute_complete',
        \ 'VimShell' : 'vimshell#complete',
        \ 'VimFiler' : 'vimfiler#complete',
        \ 'Vinarise' : 'vinarise#complete',
        \}

unite

serchにもuniteを使うほどのunite狂

L1556,開いているファイルの行数で検索方法を変えているのか.

http://lingr.com/room/vim/archives/2013/01/26#message-13706272

> L1556,開いているファイルの行数で検索方法を変えているのか.
なぜかというと、unite.vimは候補が1万を越えると極端に速度が遅くなるからです。
たとえばVimソースコードのeval.cだとすごく遅い。

http://lingr.com/room/vim/archives/2013/01/26#message-13706346
nnoremap <expr><silent> /  <SID>smart_search_expr(
      \ ":\<C-u>Unite -buffer-name=search -no-split -start-insert line/fast\<CR>",
      \ ":\<C-u>Unite -buffer-name=search -start-insert line\<CR>")

L1753unite-menuの作り方参考になる

http://lingr.com/room/vim/archives/2013/01/26#message-13706377

> ここだけ-resumeしている理由は?
resumeは他のところにもあると思います。resumeしているのはバッファを再利用したかったため。

unite-menuに最近追加された仕様

> L1759: let g:unite_source_menu_menus.enc.command_candidates = [ って配列を渡しても良かったのか・・・これで登録順に順序固定できるんですよね?
はい。これも比較的最近追加された仕様ですけど……

http://lingr.com/room/vim/archives/2013/01/26#message-13706662

その他

smartchr便利

L1853: autocmd FileType c,cpp inoremap . smartchr#loop('.', '->', '...')こういうの見てるとsmartchrって便利って思いますね

http://lingr.com/room/vim/archives/2013/01/26#message-13706456
うっとおしいコメント文字自動挿入を一括設定する

L895-914:自分で作ったpluginなのにあれですが、この設定だけであれば多分FileTypeイベントだけでいけると思います。
詳細は、以下URLの一番下の8/26追記分を参照ください。
http://d.hatena.ne.jp/deris/20120818/1345291162

http://lingr.com/room/vim/archives/2013/01/26#message-13706474
quickrun全然設定していねーや。そろそろ設定してみようかな

L1938,quickrun_config の 'exec' キーの値ってリスト渡せたのか.今まで 'platex %s && dvipdfmx %s' みたいにしてた…

http://lingr.com/room/vim/archives/2013/01/26#message-13706519

Lindan:C++ だと同じような感じでコンパイルと実行をリストで定義していますね。

http://lingr.com/room/vim/archives/2013/01/26#message-13706543

>コンパイルと実行をリストで定義
この辺り本当はなんとかしたいですね…。コンパイルだけしたい場合とかがスマートに定義できるようにしたい。

http://lingr.com/room/vim/archives/2013/01/26#message-13706585

わたしはコンパイルする設定と実行する設定を分けているな

QuickRun cpp/gccコンパイルして
QuickRun cpp/run で実行するようにしている
http://lingr.com/room/vim/archives/2013/01/26#message-13706599
パないtitlestring
"L775
let &titlestring="%{(&filetype ==# 'lingr-messages' && lingr#unread_count() > 0 )?"
      \ . " '('.lingr#unread_count().')' : ''}%{expand('%:p:.:~')}%(%m%r%w%)"
      \ . " \ %<\(%{SnipMid(fnamemodify(&filetype ==# 'vimfiler' ?"
      \ . "substitute(b:vimfiler.current_dir, '.\\zs/$', '', '') : getcwd(), ':~'),"
      \ . "80-len(expand('%:p:.')),'...')}\) - VIM"
vimfilerのWriteは補完付き

> L2353: Writeとはどういう効果を追加したのでしょうか?
補完付きのwriteです。kanaさんのmetarwをまねたもの。vimfilerが定義しています。

http://lingr.com/room/vim/archives/2013/01/26#message-13706716
サーチする時は/を\/にする

L2750 おお…これは便利そう。

http://lingr.com/room/vim/archives/2013/01/26#message-13706730
" Auto escape / and ? in search command.
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'

…そもそも検索時の/ってどういう効果だったっけ?

キーバインド

L2769:" Smart home and smart end."{{{
こういう系統のバインドは好きです

http://lingr.com/room/vim/archives/2013/01/26#message-13706943
" Smart home and smart end."{{{
nnoremap <silent> gh  :<C-u>call SmartHome("n")<CR>
nnoremap <silent> gl  :<C-u>call SmartEnd("n")<CR>
xnoremap <silent> gh  <ESC>:<C-u>call SmartHome("v")<CR>
xnoremap <silent> gl  <ESC>:<C-u>call SmartEnd("v")<CR>
" Smart home function"{{{
function! SmartHome(mode)
  let curcol = col('.')

  if &wrap
    normal! g^
  else
    normal! ^
  endif
  if col('.') == curcol
    if &wrap
      normal! g0
    else
      normal! 0
    endif
  endif

  if a:mode == "v"
    normal! msgv`s
  endif

  return ""
endfunction"}}}

" Smart end function"{{{
function! SmartEnd(mode)
  let curcol = col('.')
  let lastcol = a:mode ==# 'i' ? col('$') : col('$') - 1

  " Gravitate towards ending for wrapped lines
  if curcol < lastcol - 1
    call cursor(0, curcol + 1)
  endif

  if curcol < lastcol
    if &wrap
      normal! g$
    else
      normal! $
    endif
  else
    normal! g_
  endif

  " Correct edit mode cursor position, put after current character
  if a:mode == "i"
    call cursor(0, col(".") + 1)
  endif

  if a:mode == "v"
    normal! msgv`s
  endif

  return ""
endfunction "}}}
"}}}

> L2931:まぁ確かにテキストオブジェクトの標準バインドはいくつか押しづらいですからね
はい。これはkanaさんの設定を参考にしてます

http://lingr.com/room/vim/archives/2013/01/26#message-13707017

L2958: noremap zz (winline() == (winheight(0)+1)/ 2) ?
\ 'zt' : (winline() == 1)? 'zb' : 'zz'
zzを三役にするとは。参考にさせて貰いましょう

http://lingr.com/room/vim/archives/2013/01/26#message-13707023
http://lingr.com/room/vim/archives/2013/01/26#message-13706417