vimrc を整理した

Vim を始めた頃から無駄に機能ごとにファイル分割をして、ごちゃごちゃになっていた vimrc をこの機会にちょっと整理してみました。
1つのファイルに全部まとめたので行数は長くなったのですが、使ってなかった設定や quickrun.vim 回りの設定を見直したのでだいぶすっきりとしました。
Vim の折りたたみ機能を初めて使ってみましたがなかなか便利ですね。


C++ 回りの設定はまだちょっとごちゃごちゃしているのでもうちょっと見なおす必要がありそうですが、しばらくはこのままちょっと試してみたいと思います。
年に1回ぐらいこんな感じで vimrc を見なおしてみるのもいいですね。
次は OS 間でも問題なく使用できるようにしたい。


で、現状の vimrc とかを見たい人は続きからどうぞ。
半端無く長いです。
ちなみにわたしは全て Dropboxソースコードの管理をしているので github とかは使っていません。

[vimrc]

コメント空白行込みでだいたい 2300行ぐらいです。
まだところどころ汚いですね…。
もう2〜3回リファクタリングしたいところ。

"==========================================================
" 
"==========================================================
" {{{

" }}}


"==========================================================
" 初期設定
"==========================================================
" {{{

let $HOME=$HOME."/.vim"

" ユーザ名
if !exists("$VIMUSERNAME")
    let $VIMUSERNAME=$USERNAME
endif

let $VIMLOCALUSER=$VIMUSER."/local/".$VIMUSERNAME

if !isdirectory($VIMLOCALUSER)
    call mkdir($VIMLOCALUSER, "p")
endif

if filereadable($VIMLOCALUSER."/_vimrc")
    source $VIMLOCALUSER/_vimrc
endif
" }}}


"==========================================================
" 環境変数
"==========================================================
" {{{


" VIM データ
let $VIMHOME=$VIMUSER."/.vim"

"vimfiles
let $VIMFILES=$VIMUSER."/vimfiles"

" ユーザローカル
let $VIMUSERLOCAL=$VIMUSER."/".$VIMUSERNAME

"ソースディレクトリ
let $SOURCE_ROOT=$WORK_ROOT."/software/src"

" development
let $DEVELOPMENT=$WORK_ROOT."/software/development"

"c++ のテストディレクトリ
let $TEST_CPP=$SOURCE_ROOT."/test/cpp"
let $TEST_BOOST=$TEST_CPP."/boost"

" vim のテストディレクトリ
let $TEST_VIM=$SOURCE_ROOT."/test/vim"

" vim plugin ディレクトリ
let $VIMPLUGIN=$VIMUSER."/runtime/bundle"

" kmt
let $KMT_ROOT=$DEVELOPMENT."/cpp/lib/kmt/kmt"
let $LLVM_BIN=$LLVM_ROOT."/bin"

let $BOOST_ROOT=$BOOST_LATEST_ROOT
let $BOOST_BUILD_PATH=$BOOST_ROOT."/tools/build/v2"
let $CLANG_SDK=$LLVM_SDK.'/tools/clang'

" }}}


"==========================================================
" 基本的な設定
"==========================================================
" {{{

"shell のパスを設定
if has("gui_win32")
    set shell=C:\WINDOWS\system32\cmd.exe
endif

"バックアップファイルを作るディレクトリ
set backupdir=$HOME/vimbackup
if !isdirectory(&backupdir)
    call mkdir(&backupdir, "p")
endif


"ファイル保存の初期ディレクトリをバッファファイル位置に設定
set browsedir=buffer

"スワップファイル用のディレクトリ
set directory=$HOME/vimbackup
if !isdirectory(&directory)
    call mkdir(&directory, "p")
endif

set grepprg=d:/grep\ -nH

" Windows
set splitbelow    " 横分割したら新しいウィンドウは下に
set splitright    " 縦分割したら新しいウィンドウは右に

" 常に開いているファイルと同じディレクトリをカレントディレクトリにする
augroup group_vimrc_cd
    autocmd!
    autocmd BufEnter * execute ":lcd " . (isdirectory(expand("%:p:h")) ? expand("%:p:h") : "")
augroup END

" Undo 回数の設定 (デフォルト = 1000)
set undolevels=2000
"
" バッファを切り替えても、undo を効くように設定
" (変更をセーブせずにバッファを切り替えたいときにも、 :set hidden は役に立つが、
"  変更に気づかないまま":qa! "するという危険も伴う、諸刃の剣)
set hidden

" indent eol start を超えて、<C-w><C-u> を有効にする
set backspace=indent,eol,start


"日本語ヘルプ
helptags $VIMFILES/doc

" 日本語ヘルプを引く際に無限ループになるのを防ぐ為
" http://d.hatena.ne.jp/tyru/20100409/vim_set_notagbsearch
:set notagbsearch

" http://www.geocities.co.jp/SiliconValley-SantaClara/1183/computer/gvim.html
set iminsert=0 " インサートモードで日本語入力を ON にしない
set imsearch=0 " 検索モードで日本語入力を ON にしない

" <C-a> <C-x> で英字も増減させる
set nrformats=alpha,octal,hex
" }}}


"==========================================================
"ビジュアルの設定
"==========================================================
" {{{
" 常にカーソル位置を中心に
" set scrolloff=999
set linespace=2

"タブ文字、改行文字を表示
set list

"改行、タブ文字の設定
set listchars=tab:^-,trail:-,eol:\

"行番号を表示
set number

"閉じカッコが入力されたとき、対応するカッコを表示する
"set showmatch
" 括弧を入力した時にカーソルが移動しないように設定
set matchtime=0

" タブページのラベルを常に表示する
set showtabline=2

" ツールバーを削除
set guioptions-=T

"メニューを削除
set guioptions-=m

"チラツキ
set completeopt=menuone

" menu を無効
let did_install_default_menus = 1
let did_install_syntax_menu = 1

" バッファを閉じる時にバッファリストから削除
autocmd BufReadPre * setlocal bufhidden=delete

" ウィンドウのリサイズを抑える
set noequalalways
" }}}


"==========================================================
"コーディング
"==========================================================
" {{{
"新しい行のインデントを同じ行にする
set autoindent
filetype plugin indent on
set nocindent

" 改行時にコメントしない
set formatoptions-=ro

augroup vimrc_group_formatoptions
    autocmd!
    autocmd FileType * setlocal formatoptions-=ro
augroup END


"クリップボードをWindowsと連携
set clipboard=unnamed

"タブ文字の長さ
set tabstop=4
set shiftwidth=4

" カーソルを行頭、行末で止まらないようにする
set whichwrap=b,s,h,l,<,>,[,]

set fileformat=unix
set fileformats=unix,dos

"==================================
"エンコーディング
"==================================
" {{{
function! s:set_fileformat()
    if &fileformat != "unix"
\    && !get(b:, "set_fileformat_checked", 0)
\    && input("setlocal fileformat=unix?[y/n]") == "y"
        try
            setlocal fileformat=unix
        catch
        endtry
    endif
    let b:set_fileformat_checked = 1
"     try
"         setlocal fileformat=unix
"     catch
"     endtry
endfunction

augroup vimrc_group_set_fileformat
    autocmd!
"     autocmd BufRead * :call <SID>set_fileformat()
    autocmd BufWritePre * :call <SID>set_fileformat()
augroup END


" フォントを設定
" フォント名に日本語名を使うので、一時的に文字コードを変える
setlocal encoding=cp932
set guifont=Osaka−等幅:h11
" 文字コードを元に戻す
setlocal encoding=utf-8


"let g:verifyenc_enable = 0
setlocal encoding=utf-8
setlocal fileencodings=ucs-bom,iso-2022-jp-3,iso-2022-jp,eucjp-ms,euc-jisx0213,euc-jp,utf-8,cp932,sjis
scriptencoding utf-8
setlocal termencoding=cp932


""""""""""""""""""""""""""""""
"Windowsで内部エンコーディングがcp932以外の場合
"makeのメッセージが化けるのを回避
"http://sites.google.com/site/fudist/Home/vim-nihongo-ban/-vimrc-sample#make
""""""""""""""""""""""""""""""
if has('win32') || has('win64') || has('win95') || has('win16')
  au QuickfixCmdPost make call QFixCnv('cp932')
endif

function! QFixCnv(enc)
  if a:enc == &enc
    return
endif
  let qflist = getqflist()
  for i in qflist
    let i.text = iconv(i.text, a:enc, &enc)
  endfor
  call setqflist(qflist)
endfunction

" }}}

" }}}


"==========================================================
" pathogen
"==========================================================
" {{{

"vim plugin の読み込み
let $BUNDLE_ROOT=$VIMUSER."/runtime/bundle"
set runtimepath+=$BUNDLE_ROOT/vim-pathogen
call pathogen#runtime_prepend_subdirectories($BUNDLE_ROOT)
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()

" }}}


"==========================================================
" neobundle
"==========================================================
" {{{

set nocompatible
filetype off

if has('vim_starting')
    call neobundle#rc(expand($HOME."/neobundle"))
endif
source $VIMUSER/vimrcs/$VIMVIMRCNAME/bundles.vim

filetype plugin on
filetype indent on

" }}}


"==========================================================
" キーマッピング
"==========================================================
" {{{

" 雑多 {{{
nmap T %

" スペースを挿入
nnoremap <C-Space> i <Esc><Right>

" C-@ の誤爆防止
inoremap <C-@> <ESC>

" 検索のハイライトを消す
nnoremap <Esc><Esc> :nohlsearch<CR>

" normal モードで改行
nnoremap <C-j> O<Esc><Down>
nnoremap <C-k> <Up>dd

" カッコの補完
" inoremap "" ""<Left>
" inoremap () ()<Left>
" inoremap {} {}<Left>
" inoremap '' ''<Left>
" inoremap <> <><Left>
" }}}

" https://sites.google.com/site/fudist/Home/vim-nihongo-ban/tips#TOC-4
" カーソルを表示行で移動する。物理行移動は<C-n>,<C-p>
nnoremap j gj
nnoremap k gk
nnoremap <Down> gj
nnoremap <Up>   gk

"カーソルキーで行末/行頭の移動可能に設定。
set whichwrap=b,s,[,],<,>
nnoremap h <Left>
nnoremap l <Right>
"l を <Right>に置き換えて、折りたたみを l で開くことができるようにする。
if has('folding')
  nnoremap <expr> l foldlevel(line('.')) ? "\<Right>zo" : "\<Right>"
endif

"検索後画面の中心に。
nmap n nzz
nmap N Nzz

" 縦に連番を入力する
nnoremap <silent> co :ContinuousNumber <C-a><CR>
vnoremap <silent> co :ContinuousNumber <C-a><CR>
command! -count -nargs=1 ContinuousNumber let c = col('.')|for n in range(1, <count>?<count>-line('.'):1)|exec 'normal! j' . n . <q-args>|call cursor('.', c)|endfor

" カーソル位置の単語をヤンクした単語に置換
nnoremap <silent> ciy ciw<C-r>0<ESC>:let@/=@1<CR>:noh<CR>
nnoremap <silent> cy   ce<C-r>0<ESC>:let@/=@1<CR>:noh<CR>
nnoremap gy "0P

" 最後の編集位置へ戻る
" https://sites.google.com/site/fudist/Home/vim-nihongo-ban/tips#TOC-12
map gb `.zz
nnoremap <C-g> g;zz
nnoremap g; g,

" インデントを連続で出来るように設定
vnoremap <silent> > >gv
vnoremap <silent> < <gv

" set conceallevel の切り替え
nnoremap <silent> <Space><Space>c :execute ":set conceallevel=".((&conceallevel==0)?"2":"0")<CR>

" \ から / へ置換
vnoremap <silent> <Leader>/ :s/\\/\//g<CR>:nohlsearch<CR>
nnoremap <silent> <Leader>/ :s/\\/\//g<CR>:nohlsearch<CR>

" タブの移動
nnoremap <silent> <C-l> :tabnext<CR>
nnoremap <silent> <C-h> :tabprevious<CR>
" }}}


"==========================================================
" autocmd
"==========================================================
" {{{
augroup my_group
    autocmd!
    autocmd filetype cpp :set comments-=:\/\/
    autocmd BufReadPost *.scala setlocal filetype=scala
    autocmd BufReadPost *.txt set filetype=txt

    " 前回終了したカーソル行に移動
    autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif
augroup END
" }}}


"==========================================================
" 
"==========================================================
" {{{

" {{{

" }}}


" }}}


"==========================================================
" プラグインの設定
"==========================================================
" {{{

" {{{

" }}}

" {{{
let g:vimshell_split_command = "split"

" 呼び出し
"nnoremap <silent> <Space>vs :VimShell
nnoremap <silent> <Space>vs :execute("VimShellPop ".expand("%:p:h"))<CR>
nnoremap <silent> <Space>vsvp :VimShell $VIMPLUGIN<CR>

" 表示形式
"let g:vimshell_prompt = " % "
let g:vimshell_prompt = $VIMUSERNAME."% "

autocmd FileType int-*
    \ inoremap <buffer> <expr><silent> <C-l> unite#sources#vimshell_history#start_complete(0)

" }}}

" vim-ref {{{
function! s:ref_init()
    let g:ref_use_vimproc = 1

    " let g:ref_open="tabnew"
    " ref alc
    " let s:lynx_dir = "D:/home/work/tools/lynx2-8-7"
    let s:lynx_dir = "D:/home/work/tools/Lynx286rel4TH"
    let s:lynx = s:lynx_dir.'/lynx.exe'
    let s:cfg  = s:lynx_dir.'/lynx.cfg'

    " let g:ref_alc_cmd = "D:/home/work/tools/links/links.exe -dump %s"
    let g:ref_alc_cmd = s:lynx.' -cfg='.s:cfg.' -dump -nonumbers %s'
    let g:ref_alc_use_cache = 1
    let g:ref_alc_start_linenumber = 39 " 余計な行を読み飛ばす

    let g:ref_alc_encoding = 'Shift-JIS'
    " let g:ref_alc_encoding = 'utf-8'

    if exists('*ref#register_detection')
        " filetypeが分からんならalc
        call ref#register_detection('_', 'alc')
    endif

    let g:ref_lynx_cmd = s:lynx.' -cfg='.s:cfg.' -dump %s'
    let g:ref_lynx_use_cache = 1
    let g:ref_lynx_encoding = 'Shift-JIS'
    let g:ref_lynx_start_linenumber = 0 " 余計な行を読み飛ばす
endfunction
call s:ref_init()
" }}}

" qfixhowm {{{
let QFixHowm_Key = 'g'

" let howm_dir = $HOWM
let howm_dir = $VIMFILES."/howm"
let howm_filename        = '%Y/%m/%Y-%m-%d-%H%M%S.howm'
let howm_fileencoding    = 'utf-8'
let howm_fileformat      = 'dos'
" }}}

" reanimate.vim {{{
let g:reanimate_save_dir = $VIMLOCALUSER."/.vim/save_point"
let g:reanimate_default_save_name = "latest"
let g:reanimate_sessionoptions="curdir,folds,help,localoptions,slash,tabpages,winsize"
let g:reanimate_disables = []

" ユーザで hook する event
let s:event = {
\    "name" : "user_event",
\}

" function! s:event.load_pre(...)
function! s:event.load_pre_post(...)
    " 読み込み前に全てのバッファを保存
    :wall
    " 復元前にタブを削除する
    :tabonly
endfunction

function! s:event.save_pre(...)
    " 保存前に args を削除する
    try
        :execute "argd *"
    catch
    endtry
endfunction

call reanimate#hook(s:event)
unlet s:event

function! Last_point()
    return reanimate#is_saved() ? reanimate#last_point() : "no save"
endfunction

augroup SavePoint
    autocmd!
    autocmd VimLeavePre * ReanimateSave
    autocmd BufWritePost * ReanimateSave
augroup END

function! s:user_test()
    let self = {}
    let self.name = "user_event"
    return self
endfunction

function! s:SID()
    return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endfun
let g:reanimate_vimrc_local_filename = "vimrc_local"

nnoremap <silent> <Space>rl :execute ":tabnew ".g:reanimate_save_dir."/".reanimate#last_point()."/".g:reanimate_vimrc_local_filename<CR>
" }}}

" kaoriya {{{
""""""""""""""""""""""""""""""
"Kaoriya版に添付されているプラグインの無効化
"問題があるものもあるので一律に無効化します。
"ファイルを参照(コメント部分で gf を実行)した上で、必要なプラグインは
"let plugin_..._disableの設定行をコメント化(削除)して有効にして下さい。
""""""""""""""""""""""""""""""
" "$VIM/plugins/kaoriya/autodate.vim
" let plugin_autodate_disable  = 1
" "$VIM/plugins/kaoriya/cmdex.vim
" let plugin_cmdex_disable     = 1
" "$VIM/plugins/kaoriya/dicwin.vim
let plugin_dicwin_disable    = 1
" "$VIMRUNTIME/plugin/format.vim
" let plugin_format_disable    = 1
" "$VIM/plugins/kaoriya/hz_ja.vim
" let plugin_hz_ja_disable     = 1
" "$VIM/plugins/kaoriya/scrnmode.vim
" let plugin_scrnmode_disable  = 1
" "$VIM/plugins/kaoriya/verifyenc.vim
" let plugin_verifyenc_disable = 1


" }}}

" EasyMotion {{{
let g:EasyMotion_leader_key = '<Space>e'
"let g:EasyMotion_leader_key = '<C-m>'
nmap f <Space>ee
nmap F <Space>eb

" }}}

" itunes.vim {{{
" 一時停止
nnoremap <expr> <Space>i<Space> itunes#pause()
" 再生
nnoremap <expr> <Space>ip itunes#play()
" 停止
nnoremap <expr> <Space>is itunes#stop()
" 前の曲
nnoremap <expr> <Space>ih itunes#prev()
" 次の曲
nnoremap <expr> <Space>il itunes#next()
" }}}

" powerline{{{
let g:Powerline_theme="distinguished2"
let g:Powerline_colorscheme="distinguished2"
" let g:Powerline_theme="distinguished_with_tweetvim"
" let g:Powerline_colorscheme="distinguished_with_tweetvim"
" }}}

" Syntastic {{{

let g:syntastic_mode_map = {
\    "mode" : "active",
\    "passive_filetypes" : ["cpp"]
\}

" }}}

" caw.vim {{{
nmap <Leader>c <Plug>(caw:I:toggle)
nmap <Leader>C <Plug>(caw:I:uncomment)
vmap <Leader>c <Plug>(caw:I:toggle)
vmap <Leader>C <Plug>(caw:I:uncomment)

nmap gcy yypgcIk
vmap gcy ygvgcIP

" }}}

" vim-quickhl {{{
nmap <Space>m <Plug>(quickhl-toggle)
xmap <Space>m <Plug>(quickhl-toggle)
nmap <Space>M <Plug>(quickhl-reset)
xmap <Space>M <Plug>(quickhl-reset)

nmap <Space>j <Plug>(quickhl-match)
" }}}

" ipi#inspect {{{
call ipi#inspect()
" }}}

" auto_source.vim {{{
let g:auto_source#exclude = ".*\/vim_script\/.*"
" }}}

" restart.vim {{{
let g:restart_sessionoptions = 'blank,buffers,winpos,winsize,curdir,folds,help,localoptions,tabpages,winsize'

command!
\   RestartWithSession
\   let g:restart_sessionoptions = 'blank,buffers,winpos,winsize,curdir,folds,help,localoptions,tabpages,winsize'
\   | Restart

nnoremap <Space><Space>res :Restart<CR>
" }}}

" textmanip.vim {{{
" vmap <C-j> <Plug>(Textmanip.move_selection_down)
" vmap <C-k> <Plug>(Textmanip.move_selection_up)
" vmap <C-h> <Plug>(Textmanip.move_selection_left)
" vmap <C-l> <Plug>(Textmanip.move_selection_right)
" }}}

" copypath {{{
nnoremap <silent> <Space>cp :CopyPath<CR>
" }}}

" OpenBrowser {{{
nnoremap <Space>ecd :call OpenBrowser("file:/".expand("%:p:h"))<CR>
nnoremap <Space>ss :OpenBrowserSearch 
nmap <Space>op  <Plug>(openbrowser-smart-search)
" }}}

" ref.vim {{{
nnoremap <Space>ra :Ref alc 
" }}}

" TwitVim {{{
" " ポスト
noremap <Space>ttp :PosttoTwitter<CR>

"ID からブラウザを開く
function! Twitter_id()
    let l:cword = expand("<cword>")
    call OpenBrowser("http://twitter.com/#!/".l:cword)
    return ""
endfunction
nnoremap <silent><expr> <Space>top Twitter_id()
let twitvim_count = 100

" ポスト
noremap <Space>tp :TweetVimSay<CR>
" }}}

" evervim {{{
" " 新規作成
" noremap <Space>evc :EvervimCreateNote<CR>
" 
" " タグ一覧
" noremap <Space>evt :EvervimListTags<CR>
" 
" " 検索
" noremap <Space>evs :EvervimSearchByQuery
" }}}

" vimfiler {{{
let g:vimfiler_safe_mode_by_default=0
let g:unite_kind_file_use_trashbox = 1
let g:vimfiler_as_default_explorer = 1

nnoremap <silent> <Space>vfvf :VimFilerTab $VIMFILES<CR>
nnoremap <silent> <Space>vftc :VimFilerTab $TEST_CPP<CR>
nnoremap <silent> <Space>vftb :VimFilerTab $TEST_BOOST<CR>
nnoremap <silent> <Space>vftv :VimFilerTab $TEST_VIM<CR>
nnoremap <silent> <Space>vfvp :VimFilerTab $VIMPLUGIN<CR>
nnoremap <silent> <Space>vf :execute "VimFilerTab ".substitute(expand("%:p:h"), "\\", "/", "g")
" }}}

" neocomplcache {{{

" 有効にする
let g:neocomplcache_enable_at_startup=1

" キーワード補完を行う入力数
let g:neocomplcache_auto_completion_start_length=2

let g:neocomplcache_enable_ignore_case=0 " 大文字、小文字を無視する

"入力に大文字が含まれている場合は、大文字・小文字を無視する
let g:neocomplcache_enable_smart_case=0

"大文字を入力したときに、それを単語の区切りとしてあいまい検索を行う
let g:neocomplcache_enable_camel_case_completion=1

"_を入力したときに、それを単語の区切りとしてあいまい検索を行う
let g:neocomplcache_enable_underbar_completion=1

"スニペットのディレクトリ
if !exists("g:neocomplcache_snippets_dir")
    let g:neocomplcache_snippets_dir=""
endif
let g:neocomplcache_snippets_dir=$VIMUSER.'/snippets'.','.g:neocomplcache_snippets_dir

"<TAB>でスニペット補完
if g:neocomplcache_enable_at_startup
  imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
endif

"<CR>(ENTER)で候補を閉じ改行
inoremap <expr><CR>  neocomplcache#close_popup() . "\<CR>"

"1つ前の補完を取り消す
inoremap <expr><C-g> neocomplcache#undo_completion()

"<C-h>や<BS>を押したときに確実にポップアップを削除す
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"

"現在選択している候補を確定する
inoremap <expr><C-y> neocomplcache#close_popup()

"現在選択している候補をキャンセルし、ポップアップを閉じる
inoremap <expr><C-e> neocomplcache#cancel_popup()

let g:neocomplcache_enable_cursor_hold_i=0

let g:neocomplcache_max_list=1000
" }}}

" unite.vim {{{

" キーマッピング {{{
nnoremap <Space>ub    :Unite buffer -input=!split<CR>
nnoremap <Space>ufm   :Unite file_mru<CR>
nnoremap <Space>udm   :Unite directory_mru<CR>
nnoremap <Space>urm   :UniteResume<CR>
nnoremap <Space>uff   :Unite file<CR>
nnoremap <Space>uol   :Unite outline<CR>
nnoremap <Space>unb   :Unite neobundle<CR>
nnoremap <Space>ugr   :Unite grep<CR><CR>
nnoremap <Space>um    :Unite menu<CR>
nnoremap <Space>urrr  :Unite rofi<CR>
nnoremap <Space>url   :Unite reanimate -default-action=reanimate_load<CR>
nnoremap <Space>urs   :Unite reanimate -default-action=reanimate_save<CR>
nnoremap <Space>umes  :Unite output:mes<CR>
nnoremap <Space>uqh   :Unite qfixhowm:nocache<CR>
nnoremap <Space>uqh   :Unite qfixhowm:nocache<CR>
nnoremap <Space>ubb   :Unite boost-online-doc -default-action=ref_lynx_tabnew<CR>
" nnoremap <Space>ub   :Unite bookmark<CR>
" nnoremap <Space>ucmd  :Unite commandsCR>
" nnoremap <Space>uw    :Unite window<CR>
" nnoremap <Space>ut    :Unite tab<CR>

inoremap <C-y> <Esc>:Unite history/yank -direction=belowright -winheight=12<CR>

" }}}

" unite-action {{{
" unite-kinds start {{{
let start = {
            \ 'description' : 'start',
            \ 'is_selectable' : 1,
            \ }
function! start.func(candidates)
    for l:candidate in a:candidates
    call system("cmd /c start ".l:candidate.action__path)
    endfor
endfunction
call unite#custom_action('openable', 'start', start)
unlet start
" }}}

" 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
" }}}

" OpenBrowser {{{
let openbrowser = {
            \ 'description' : 'OpenBrowser',
            \ 'is_selectable' : 1,
            \ }
function! openbrowser.func(candidates)"{{{
    for l:candidate in a:candidates
        call openbrowser#open(l:candidate.word)
    endfor
endfunction"}}}

call unite#custom_action('common', 'openbrowser', openbrowser)
unlet openbrowser
" }}}

" OpenBrowser file:/ {{{
let openbrowser_file = {
            \ 'description' : 'OpenBrowser file:/{word}',
            \ 'is_selectable' : 1,
            \ }
function! openbrowser_file.func(candidates)"{{{
    for l:candidate in a:candidates
        call openbrowser#open('file:/'.l:candidate.action__path)
    endfor
endfunction"}}}
call unite#custom_action('openable', 'openbrowser_file', openbrowser_file)
unlet openbrowser_file
" }}}

" OpenBrowserSearch {{{
let openbrowser_search = {
            \ 'description' : 'OpenBrowserSearch for word',
            \ 'is_selectable' : 1,
            \ }
function! openbrowser_search.func(candidates)"{{{
    for l:candidate in a:candidates
        call openbrowser#search(l:candidate.word)
    endfor
endfunction"}}}
call unite#custom_action('common', 'openbrowser_search', openbrowser_search)
unlet openbrowser_search
" }}}

" tab drop {{{
let action = {
\    'description' : 'tab drop',
\    'is_selectable' : 1,
\ }
function! action.func(candidates)"{{{
    for candidate in a:candidates
        let bufpath = substitute(expand("%:p"), "\\", "\/", "g")
        if bufpath != candidate.action__path
            call unite#util#smart_execute_command('tab drop', candidate.action__path)
        endif
        call unite#take_action('open', candidate)
    endfor
endfunction"}}}
call unite#custom_action('openable', 'tabdrop', action)
unlet action
" }}}

" }}}

" unite-menu {{{
if !exists("g:unite_source_menu_menus")
    let g:unite_source_menu_menus = {}
endif

" directory {{{

let s:commands = {
\    'description' : 'Test menu',
\}

let s:commands.candidates = {
\    "BoostTest" : "VimFiler $TEST_BOOST",
\    "C++Test"   : "VimFiler $TEST_CPP",
\    "VimFiles"  : "VimFiler $VIMFILERS",
\    "Vim Test"  : "VimFiler $TEST_VIM",
\    "Bundle"    : "VimFiler $VIMPLUGIN",
\    "Colorscheme" : "OpenBrowser file:/D:/home/Dropbox/work/vim/runtime/bundle/colorscheme/colors"
\}

function s:commands.map(key, value)
    return {
\       'word' : a:key,
\       'kind' : 'command',
\       'action__command' : a:value,
\     }
endfunction

let g:unite_source_menu_menus["directory"] = deepcopy(s:commands)
unlet s:commands

" 呼び出しのキーマップ
nnoremap <silent> <Space>dd :Unite menu:directory<CR>
" }}}

" unite-shortcut {{{
" コマンドを登録して unite.vim で選択して起動
let s:commands = {
\    'description' : 'Test menu',
\}

let s:commands.candidates = {
\    "BoostTest" : "VimFiler $TEST_BOOST",
\    "C++Test"   : "VimFiler $TEST_CPP",
\    "ghci"      : "VimShellInteractive ghci",
\    "python"    : "VimShellInteractive python",
\    "Unite Beautiful Attack" : "Unite -auto-preview colorscheme",
\    "Boost.MPL Ref" : "OpenBrowser http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/refmanual_toc.html",
\    "VimShellPop" : "VimShellPop",
\    "Blog Edit"   : "OpenBrowser http://d.hatena.ne.jp/osyo-manga/edit",
\    "ideone"   : "OpenBrowser http://ideone.com/",
\    "AllMap"   : "Unite output:AllMap",
\    "LastBuf.vim : open last closed buffersLastBuf" : ":LastBuf",
\}

function s:commands.map(key, value)
    return {
\       'word' : a:key,
\       'kind' : 'command',
\       'action__command' : a:value,
\     }
endfunction

let g:unite_source_menu_menus["shortcut"] = deepcopy(s:commands)
unlet s:commands

" 呼び出しのキーマップ
nnoremap <silent> <Space>ll :Unite menu:shortcut<CR>
" }}}

" unite-action-quickrun {{{
let s:action = {
      \ 'description' : 'quickrun compile command',
      \ 'is_selectable' : 1,
      \ }

function! s:action.func(candidates)
    for val in a:candidates
        let g:quickrun_compile_command[&filetype] = val.word
    endfor
endfunction
call unite#custom_action('common', 'quickrun_compile_command', s:action)
unlet s:action


let s:unite_source = {
\   "name" : "quickrun-select",
\    "default_action" : "quickrun_compile_command"
\}

function! s:unite_source.gather_candidates(args, context)
    let cmds = filter(deepcopy(g:quickrun_config), "exists('v:val.type') ? v:val.type == &filetype : 0")

    return sort(values(map(cmds, "{
\       'word' : v:key,
\       'source' : 'quickrun-select',
\       'kind' : 'common',
\   }")))
endfunction

call unite#define_source(s:unite_source)

nnoremap <silent> <silent> <Space>qr :Unite quickrun-select -quick-match<CR>



" }}}

" }}}

" 設定 {{{
call unite#custom_default_action('directory' , 'tabvimfiler')

let g:unite_data_directory = $VIMLOCALUSER."/.vim/.unite"
let g:unite_source_history_yank_enable=1

" file mru の保存数
let g:unite_source_file_mru_limit = 5000

" default action
call unite#custom_default_action("directory_mru", "vimfiler")
" }}}

" unite-source {{{

" templatefiles {{{
" Unite から選択して、template file を挿入する
" filetype のディレクトリから選択を行う
if !exists("g:templatefiles")
    let g:templatefiles=$VIMUSER."/templatefiles"
endif
nnoremap <Space>utmp :call l:unite_templatefiles(g:templatefiles)<CR>
function! l:unite_templatefiles(dir)
    call unite#start(['file_rec'], {
    \'input' : substitute(a:dir, '\', '/', 'g').'/'.&filetype,
    \'default_action' : 'read'
    \})
endfunction

nnoremap <Space>vftmp :VimFiler $TEMPLAETFILES<CR>
" }}}

" unite-quickfix {{{
function! s:qflist_to_unite(val)
    let fname = a:val.bufnr == 0 ? "" : bufname(a:val.bufnr)
    let line  = fname == "" ? "" : a:val.lnum
    let text  = a:val.text
    let fname_env = pathshorten(fname)
    let error = a:val.type == "e" ? "|error ":""
    return {
    \ "word": fname_env."|".line.error."| ".text,
    \ "source": "quickfix",
    \ "kind": "jump_list",
    \ "action__path": fname,
    \ "action__line": line,
    \ "action__pattern": a:val.pattern,
    \ "is_multiline" : 1,
    \ }
endfunction

let s:quickfix_source = {}
let s:quickfix_source.name = "quickfix"
let s:quickfix_source.syntax = "uniteSource__quickfix"

function! s:quickfix_source.gather_candidates(args, context)
" function! s:quickfix_source.async_gather_candidates(args, context)
    return map(getqflist(), "s:qflist_to_unite(v:val)")
endfunction


let s:quickfix_source.hooks = {}

call unite#define_source(s:quickfix_source)
unlet s:quickfix_source
" }}}

" qfixfowm {{{
let s:source = {
\    "name" : "qfixhowm",
\    "description" : "qfixhowm",
\    "action_table" : {
\        "delete" : {
\            "description" : "delete qfixmemo",
\            "is_selectable" : 1,
\            "is_invalidate_cache" : 1,
\            "is_quit" : 0
\        }
\    }
\}

function! s:source.action_table.delete.func(candidates)
    let input = input("Really force delete files? [yes/no]")
    if input == "yes" || input == "y"
        for candidate in a:candidates
            call delete(candidate.action__path)
        endfor
    endif
endfunction

function! s:source.gather_candidates(args, context)
"     call qfixmemo#ListCmd()
"     if get(a:args, 0, "") == "close"
"         close
"     endif
    let tmp = get(g:, "QFixListAltOpen", 0)
    let g:QFixListAltOpen = 1
    if get(a:args, 0, "") == "nocache"
        let list = qfixmemo#ListCmd("nocache")
    else
        let list = qfixmemo#ListCmd()
    endif
    let g:QFixListAltOpen = tmp
    let new_memo = [{
\        "word" : "[ new memo ]",
\        "default_action" : "new_memo",
\        "kind" : "qfixlist_new_memo"
\    }]
"     PP list

    return new_memo + map(copy(list), '{
\        "word" : "(".fnamemodify(v:val.filename, ":t:r").") ".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


function! QFixListAltOpen(qflist, dir)
    return a:qflist
endfunction


" }}}

" }}}

" }}}

" clang_complete {{{
if isdirectory($LLVM_ROOT)

    let $PAHT=$LLVM_ROOT.";".$PATH

    let g:clang_conceal_snippets=1
    " let g:clang_snippets=1
    let g:clang_complete_auto=1
    let g:clang_sort_algo="none"

    " let g:clang_exec =$LLVM_ROOT.'/bin/clang.exe'

    let g:clang_exec = $LLVM_BIN."/clang.exe"
    let g:clang_use_library=1
    let g:clang_library_path = $LLVM_BIN
    let g:clang_debug=0
    let g:clang_auto_select = 0
    let g:clang_complete_copen=1

    let g:clang_user_options =
        \ '-fms-extensions -fgnu-runtime '.
        \ '-include malloc.h '.
        \ '-std=gnu++0x '

    " let g:clang_complete_macros=1
    " let g:clang_complete_patterns=0

    " neocomplcache_clang {{{
    " let g:neocomplcache_clang_use_library  = 1
    " let g:neocomplcache_clang_debug = 1
    " let g:neocomplcache_clang_library_path = $LLVM_BIN
    " let g:neocomplcache_clang_user_options = g:clang_user_options
    "let g:neocomplcache_clang_user_options =
        \ '-I '.$LLVM_ROOT.'/lib/clang/3.1/include '.
        \ '-I C:/MinGW/lib/gcc/mingw32/4.5.2/include '.
        \ g:get_include_dirs_option().
        \ '-fms-extensions -fgnu-runtime '.
        \ '-include malloc.h '
    " }}}

endif
" }}}


" quickrun {{{

" quickrun-outputter {{{

" outputter-unit {{{
let s:outputter = quickrun#outputter#buffered#new()
let s:outputter.config = {}

function! s:outputter.init(session)
endfunction

function! s:outputter.output(data, session)
    let data = a:data
    if &l:fileformat ==# 'dos'
        let data = substitute(data, "\r\n", "\n", 'g')
    endif
    execute ":Unite output:echo\ "."'".data."'"
endfunction

function! s:outputter.finish(session)
endfunction
call quickrun#register_outputter("unite", s:outputter)
unlet s:outputter
" }}}

" location-list {{{
let s:outputter = quickrun#outputter#buffered#new()
let s:outputter.config = {
\     'errorformat': '&errorformat',
\ }

function! s:outputter.finish(session)
    try
        let errorformat = &l:errorformat
        let &l:errorformat = self.config.errorformat
        lgetexpr self._result
        cwindow
        for winnr in range(1, winnr('$'))
            if getwinvar(winnr, '&buftype') ==# 'quickfix'
                call setwinvar(winnr, 'quickfix_title', 'quickrun: ' .
                \     join(a:session.commands, ' && '))
                break
            endif
        endfor
    finally
        let &l:errorformat = errorformat
    endtry
endfunction
call quickrun#register_outputter("location_list", s:outputter)
unlet s:outputter
" }}}

" silent quickfix {{{
let s:outputter = quickrun#outputter#quickfix#new()
function! s:outputter.finish(session)
    call call(quickrun#outputter#quickfix#new().finish, [a:session], self)
    :cclose
endfunction

" quickrun に登録
call quickrun#register_outputter("silent_quickfix", s:outputter)
" }}}

" silent-location-list {{{
let s:outputter = quickrun#outputter#buffered#new()
let s:outputter.config = {
\     'errorformat': '&errorformat',
\ }

function! s:outputter.finish(session)
    try
        let errorformat = &l:errorformat
        let &l:errorformat = self.config.errorformat
        lgetexpr self._result
        for winnr in range(1, winnr('$'))
            if getwinvar(winnr, '&buftype') ==# 'quickfix'
                call setwinvar(winnr, 'quickfix_title', 'quickrun: ' .
                \     join(a:session.commands, ' && '))
                break
            endif
        endfor
    finally
        let &l:errorformat = errorformat
    endtry
endfunction
call quickrun#register_outputter("silent_location_list", s:outputter)
unlet s:outputter
" }}}

" static syntax check location-list {{{
let s:outputter = quickrun#outputter#buffered#new()
let s:outputter.config = {
\     'errorformat': '&errorformat',
\ }

function! s:outputter.finish(session)
    try
        let errorformat = &l:errorformat
        let &l:errorformat = self.config.errorformat
        lgetexpr self._result
        for winnr in range(1, winnr('$'))
            if getwinvar(winnr, '&buftype') ==# 'quickfix'
                call setwinvar(winnr, 'quickfix_title', 'quickrun: ' .
                \     join(a:session.commands, ' && '))
                break
            endif
        endfor
    finally
        let &l:errorformat = errorformat
    endtry
    :HierUpdate
    " quickfix への出力後に quickfixstatus を有効に
    :QuickfixStatusEnable
endfunction
call quickrun#register_outputter("static_syntax_check_location_list", s:outputter)
" }}}

" buffer {{{
let s:outputter = {
\   'config': {
\     'append': 0,
\     'split': '%{winwidth(0) * 2 < winheight(0) * 5 ? "" : "vertical"}',
\     'into': 0,
\     'running_mark': ':-)',
\   },
\ }

function! s:outputter.init(session)
  let winnr = winnr()
  call s:open_result_window(self.config.split)
  if !self.config.append
    silent % delete _
  endif
  let self._line = line('$')
  call s:set_running_mark(self.config.running_mark)
  execute winnr 'wincmd w'
endfunction

function! s:outputter.output(data, session)
  let winnr = winnr()
  call s:open_result_window(self.config.split)
  let oneline = line('$') == 1
  let data = getline('$') . a:data
  silent $ delete _
  if data =~# '\n$'
    " :put command do not insert the last line.
    let data .= "\n"
  endif

  " XXX 'fileformat' of a new buffer depends on 'fileformats'.
  if &l:fileformat ==# 'dos'
    let data = substitute(data, "\r\n", "\n", 'g')
  endif

  silent $ put = data
  if oneline
    silent 1 delete _
  endif
  call s:set_running_mark(self.config.running_mark)
  redraw
  execute winnr 'wincmd w'
endfunction

function! s:outputter.finish(session)
  let winnr = winnr()

  if self._line == 1  " no output
    " clear the buffer if already opened.
    if exists('s:bufnr') && bufwinnr(s:bufnr) != -1
      execute bufwinnr(s:bufnr) 'wincmd w'
      silent % delete _
      if !self.config.into
        execute winnr 'wincmd w'
      endif
    endif
    return
  endif
    
  call s:open_result_window(self.config.split)
  execute self._line
  silent normal! zt
  if !self.config.into
    execute winnr 'wincmd w'
  endif
  redraw
endfunction


function! s:open_result_window(sp)
  if !exists('s:bufnr')
    let s:bufnr = -1  " A number that doesn't exist.
  endif
  if !bufexists(s:bufnr)
    execute a:sp 'split'
    edit `='[quickrun output]'`
    let s:bufnr = bufnr('%')
    nnoremap <buffer> q <C-w>c
    setlocal bufhidden=hide buftype=nofile noswapfile nobuflisted
    setlocal filetype=quickrun
  elseif bufwinnr(s:bufnr) != -1
    execute bufwinnr(s:bufnr) 'wincmd w'
  else
    execute a:sp 'split'
    execute 'buffer' s:bufnr
  endif
  if exists('b:quickrun_running_mark')
    silent undo
    unlet b:quickrun_running_mark
  endif
endfunction

function! s:set_running_mark(mark)
  if a:mark !=# '' && !exists('b:quickrun_running_mark')
    let &undolevels = &undolevels  " split the undo block
    silent $ put =a:mark
    let b:quickrun_running_mark = 1
  endif
endfunction

call quickrun#register_outputter("my_buffer", s:outputter)
unlet s:outputter
" }}}

" close_buffer {{{
let s:outputter = quickrun#outputter#buffer#new()
let s:outputter.is_close = 1
function! s:outputter.output(data, session)
    let self.is_close = empty(a:data)
    call call(quickrun#outputter#buffer#new().output, [a:data,a:session], self)
endfunction

function! s:outputter.finish(session)
    call call(quickrun#outputter#buffer#new().finish, [a:session], self)
    if self.is_close
"         silent % delete _
        bwipeout! [quickrun
    endif
endfunction

call quickrun#register_outputter("close_buffer", s:outputter)
unlet s:outputter
" }}}


" }}}

" unite_quickfix outputter {{{
let s:outputter = quickrun#outputter#multi#new()
let s:outputter.config.targets = ["my_buffer", "quickfix"]
function! s:outputter.init(session)
    " quickfix を閉じる
    :UniteClose cpp-compile-error
"     :cclose
    " 元の処理を呼び出す
    call call(quickrun#outputter#multi#new().init, [a:session], self)
endfunction

function! s:outputter.finish(session)
    call call(quickrun#outputter#multi#new().finish, [a:session], self)
    :cclose

    " 出力バッファの削除
"     silent % delete _
    bwipeout! [quickrun
    
    if len(getqflist())
"     if len(getloclist("%"))
        execute "Unite -buffer-name=cpp-compile-error -no-quit -direction=belowright -winheight=12 quickfix"
    endif

    :HierUpdate
    " quickfix への出力後に quickfixstatus を有効に
    :QuickfixStatusEnable
endfunction

" quickrun に outputter を登録
call quickrun#register_outputter("unite_quickfix", s:outputter)
unlet s:outputter
" }}}

" g:quickrun_config の初期化
if !exists("g:quickrun_config")
    let g:quickrun_config={}
endif

function! g:set_quickrun_config(name, base, config)
    let base = type(a:base) == type("") ? g:quickrun_config[a:base] : a:base
    let result = deepcopy(base)
    call extend(result, a:config, "force")
    let g:quickrun_config[a:name] = deepcopy(result)
endfunction


" デフォルトの設定
let g:quickrun_config["_"] = {
    \ "runner/vimproc/updatetime" : 80,
    \ "outputter/buffer/split" : ":rightbelow 8sp",
    \ "outputter/my_buffer/split" : ":rightbelow 8sp",
    \ "outputter/close_buffer/split" : ":rightbelow 8sp",
    \ "outputter/error/error" : "unite_quickfix",
    \ "outputter/error/success" : "close_buffer",
    \ "outputter" : "error",
    \ "runner" : "vimproc",
    \ "outputter/buffer/running_mark" : "バン(∩`・ω・)バンバンバンバン゙ン",
    \ "outputter/my_buffer/running_mark" : "バン(∩`・ω・)バンバンバンバン゙ン",
    \ "outputter/close_buffer/running_mark" : "バン(∩`・ω・)バンバンバンバン゙ン",
\ }


" 実行
let g:quickrun_config["run/vimproc"] = {
    \ "exec": "%s:p:r %a",
    \ "output_encode" : "utf-8",
    \ "runner" : "vimproc",
    \ "outputter" : "buffer"
\ }

let g:quickrun_config["run/system"] = {
    \ "exec": "%s:p:r %a",
    \ "output_encode" : "utf-8",
    \ "runner" : "system",
    \ "outputter" : "buffer"
\ }

let g:quickrun_config["run/vimproc/pause"] = {
    \ "exec": "%s:p:r %a && pause",
    \ "output_encode" : "utf-8",
    \ "runner" : "shell",
    \ "outputter" : "buffer"
\ }

" QuickRun の呼び出しを行うキーバインド
" とりあえず、ビルドと実行を分けて設定
let g:quickrun_compile_command = {"_" : {} }
let g:quickrun_run_command= { "_" : "run/vimproc"}
let g:prev_compile_file = ""

" 1つ前にコンパイルしたファイルでコンパイル
nnoremap <C-F8> :execute ":QuickRun -src ".join(readfile(g:prev_compile_file, 'b'), "\n").
    \ <SID>quickrun_compile_command(
    \    get(g:quickrun_compile_command, &filetype, g:quickrun_compile_command._))<CR>

" コンパイル
" nnoremap <silent> <C-F7> :execute ":QuickRun ".g:quickrun_compile_command[&filetype]<CR>
nnoremap <C-F7> :execute ":QuickRun ".
    \ <SID>quickrun_compile_command(
    \    get(g:quickrun_compile_command, &filetype, g:quickrun_compile_command._))<CR>
function! s:quickrun_compile_command(command)
    :cgetexpr ""
    :cclose
    let g:prev_compile_file = expand("%:p")
    PP a:command
    if empty(a:command)
        return ""
    endif
        return a:command
endfunction

" 実行
nnoremap <C-F5> :execute ":QuickRun ".
    \ <SID>quickrun_run_command(
    \    get(g:quickrun_run_command, &filetype, g:quickrun_run_command._))<CR>
function! s:quickrun_run_command(command)
    if empty(a:command)
        return ""
    endif
        return a:command
endfunction

nnoremap <C-F6> :call openbrowser#open("file:/".expand("%:p:r").".exe")<CR>

" }}}

" }}}


"==========================================================
" Vim scirpt
"==========================================================
" {{{

" {{{

" }}}


" vim hack {{{
" http://vim-users.jp/vim-hacks-project/

" 次の()へ移動する {{{
" http://vim-users.jp/2011/04/hack214/
onoremap ) t)
onoremap ( t(
vnoremap ) t)
vnoremap ( t(
" }}}

" Hack #125: 矩形選択で自由に移動する {{{
" http://vim-users.jp/2010/02/hack125/
set virtualedit+=block
" }}}

" AllMaps {{{
" http://vim-users.jp/2011/02/hack203/
command!
\   -nargs=* -complete=mapping
\   AllMaps
\   map <args> | map! <args> | lmap <args>
" }}}

" Capture {{{
" http://d.hatena.ne.jp/tyru/20100427/vim_capture_command
command!
\   -nargs=+ -complete=command
\   Capture
\   call s:cmd_capture(<q-args>)

function! s:cmd_capture(q_args) "{{{
    redir => output
    silent execute a:q_args
    redir END
    let output = substitute(output, '^\n\+', '', '')

    belowright new

    silent file `=printf('[Capture: %s]', a:q_args)`
    setlocal buftype=nofile bufhidden=unload noswapfile nobuflisted
    call setline(1, split(output, '\n'))
endfunction "}}}
" }}}

" Hack #202: 自動的にディレクトリを作成する {{{
" http://vim-users.jp/2011/02/hack202/
augroup vimrc-auto-mkdir  " {{{
  autocmd!
  autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang)
  function! s:auto_mkdir(dir, force)  " {{{
    if !isdirectory(a:dir) && (a:force ||
    \    input(printf('"%s" does not exist. Create? [y/N]', a:dir)) =~? '^y\%[es]$')
      call mkdir(iconv(a:dir, &encoding, &termencoding), 'p')
    endif
  endfunction  " }}}
augroup END  " }}}
" }}}

" Hack #62: カーソル下のキーワードをバッファ内全体で置換する {{{
" http://vim-users.jp/2009/08/hack62/
nnoremap <expr> s* ':%substitute/\<' . expand('<cword>') . '\>/'
" }}}

" }}}

"全角スペースを表示 {{{
"http://sites.google.com/site/fudist/Home/vim-nihongo-ban/vim-color
"コメント以外で全角スペースを指定しているので scriptencodingと、
"このファイルのエンコードが一致するよう注意!
"全角スペースが強調表示されない場合、ここでscriptencodingを指定すると良い。
"scriptencoding cp932

function! s:zenkakuSpace()
  "ZenkakuSpaceをカラーファイルで設定するなら次の行は削除
  highlight ZenkakuSpace cterm=underline ctermfg=darkgrey gui=underline guifg=darkgrey
  "全角スペースを明示的に表示する。
  silent! match ZenkakuSpace / /
endfunction
if has('syntax')
  augroup ZenkakuSpace
    autocmd!
    autocmd VimEnter,BufEnter * call <SID>zenkakuSpace()
  augroup END
endif
" }}}

" バッファの削除 {{{
function! s:delete_hide_buffer()
    let list = filter(range(1, bufnr("$")), "bufexists(v:val) && !buflisted(v:val)")
    for v in list
        execute "bw ".v
    endfor
endfunction

command! -bar DeleteHideBuffer :call s:delete_hide_buffer()


function! s:delete_no_file_buffer()
    let list = filter(range(1, bufnr("$")),
\        'bufexists(v:val) && !filereadable(expand("#".v:val.":p"))'
\    )
    for v in list
        execute "bw ".v
    endfor
endfunction

command! -bar DeleteNoFileBuffer :call s:delete_no_file_buffer()

" }}}

" 各 filetype ごとの設定ファイル {{{
" after/ftplugin/{&filetype}.vim ファイルを開く
" ディレクトリは各環境にあわせて
let $AFTER_FTPLUGIN = $BUNDLE_ROOT."/after/ftplugin"
" nnoremap <silent> <Space><CR> :execute ":e ".$AFTER_FTPLUGIN."/".&filetype.".vim"<CR>
nnoremap <silent> <Space><CR> :execute ":tabnew ".$AFTER_FTPLUGIN."/".&filetype.".vim"<CR>
" }}}

" 雑多 {{{
function! s:flatten(seq)
    let result = []
    for n in a:seq
        if(type(n) == type([]))
            let result = result + s:flatten(n)
        else
            let result = result + [n]
        endif
        unlet n
    endfor
    return result
endfunction

function! s:delete_window()
    let tabpagelist = s:flatten(map(range(tabpagenr("$")), "tabpagebuflist(v:val+1)"))
    if count(tabpagelist, winbufnr("%")) == 1
        :bdelete
    else
        :quit
    endif
endfunction

" }}}

" neocomplcache が作成した tag ファイルのパスを tags に追加する {{{
function! s:TagsUpdate()
    " setlocal tags に neocomplcache が出力した tag ファイルのパスを追加する
    " include している tag ファイルが毎回同じとは限らないので1度初期化
    setlocal tags=
    for filename in neocomplcache#sources#include_complete#get_include_files(bufnr('%'))
        execute "setlocal tags+=".neocomplcache#cache#encode_name('tags_output', filename)
    endfor
endfunction

augroup popup_tags
command!
    \ -nargs=? PopupTags
    \ Unite -default-action=tabdrop -immediately -direction=belowright -winheight=12 tag/include:<args>
augroup END

function! s:get_func_name(word)
    let end = match(a:word, '<\|[\|(')
    return end == -1 ? a:word : a:word[ : end-1 ]
endfunction

noremap <silent> g<C-]> :<C-u>execute "PopupTags ".expand('<cword>')<CR>
noremap <silent> G<C-]> :<C-u>execute "PopupTags "
    \.substitute(<SID>get_func_name(expand('<cWORD>')), '\:', '\\\:', "g")<CR>
nnoremap <Space>ns :execute "tabnew\|:NeoComplCacheEditSnippets ".&filetype<CR>
" }}}

" タブ表示 {{{
function! g:tablabel()
    let label = &ft == "howm_memo" ? getline(1)
\         : fnamemodify(expand('%:p'),':h:t').'/'.expand('%:t')

    let bufnrlist = tabpagebuflist(v:lnum)

    " このタブページに変更のあるバッファがるときには '+' を追加する
    for bufnr in bufnrlist
    if getbufvar(bufnr, "&modified")
        let label = '+ '.label
        break
    endif
    endfor
    return label
endfunction
set guitablabel=%{g:tablabel()}

nmap gf <C-w>gf
" }}}

" }}}


"==========================================================
" 各言語の設定
"==========================================================
" {{{

" {{{

" }}}

" dart {{{
let s:dart_cmd = "D:/home/bin/dart/dart-sdk/bin/dart.exe"

let g:quickrun_config.dart = {
\    "command" : s:dart_cmd,
\}

augroup dart_group
    autocmd BufReadPost *.dart set shiftwidth=4 noexpandtab
augroup END
" }}}

" cpp {{{

let c_comment_strings=1
let c_no_curly_error=1


" get_include_dirs_option {{{
function! g:get_include_dirs_option()
    let include_dirs = ""
    for dir in split(&path, ",")
        if !( dir == "" || dir == "." || dir == ".." 
        \    || match(dir,"mingw") != -1 )
            let include_dirs = " -I ".dir." ".include_dirs
        endif
    endfor
    return include_dirs
endfunction
" }}}


" init quickrun {{{
function! g:update_compiler_option()
    let include_dirs = g:get_include_dirs_option()
    
    " gcc のコンパイルオプション
"    let l:gcc_option= include_dirs.'-Wall -fexec-charset=CP932 '
    let l:gcc_option= include_dirs.' -Wall -DBOOST_THREAD_USE_LIB'
"     let l:gcc_lib_path=' -lws2_32 '
    let l:gcc_lib_path=' '
"     let l:gcc_lib_path=' -lpthread -L'.$BOOST_LATEST_ROOT.'/stage/lib -lboost_thread-mgw45-mt-1_48 -lboost_filesystem-mgw45-mt-1_48'
"     let l:gcc_lib_path=' -L'.$BOOST_LATEST_ROOT.'/stage/lib -lboost_system-mgw47-mt-1_48 -lboost_filesystem-mgw47-mt-1_48'
    
    " msvc のコンパイルオプション
    let l:msvc_debug_option =
        \"/nologo /W3 /WX- /Od /Ob1 /Oy- /DWIN32 ".
        \"/D_DEBUG /D_CONSOLE /D_UNICODE /DUNICODE ".
        \"/Gm /Zi /EHsc /RTC1 /MTd /GS ".include_dirs
    
    let l:msvc_release_option = 
        \" /DWIN32 /D_CONCOLE /DNDEBUG ".
        \"/nologo /MT /EHsc /GR ".include_dirs

    let l:msvc_release_link_option = " "

    " let l:msvc_release_link_option=
    "     \" /link -LIBPATH:" ".
    "     \" 'kernel32.lib' 'user32.lib' 'gdi32.lib' ".
    "     \"'comdlg32.lib' 'advapi32.lib' 'shell32.lib' 'ole32.lib' ".
    "     \"'oleaut32.lib' 'uuid.lib' 'odbc32.lib' 'odbccp32.lib' "

    let l:msvc_release_link_option=
        \" /link -LIBPATH:".$BOOST_LATEST_ROOT."/stage/lib ".
        \" 'kernel32.lib' 'user32.lib' 'gdi32.lib' ".
        \"'comdlg32.lib' 'advapi32.lib' 'shell32.lib' 'ole32.lib' ".
        \"'oleaut32.lib' 'uuid.lib' 'odbc32.lib' 'odbccp32.lib' "
    
    let l:msvc_debug_link_option = l:msvc_release_link_option."/DEBUG "
    
    let l:quickrun_cpp_default = {
        \ "type" : "cpp",
        \ "exec": ["rm -f %s:p:r".(has('win32') ? ".exe" : "")],
        \ "outputter" : "unite_quickfix",
        \ "runner" : "vimproc",
    \ }

    call g:set_quickrun_config("test", l:quickrun_cpp_default, {
\        "command" : "clang",
\        "exec"    : "%c %o %s:p",
\    })

    
    " msvc デバッグビルド
    call g:set_quickrun_config("msvc_debug", l:quickrun_cpp_default, {
\        "command" : "cl",
\        "exec"    : "%c %o %s:p".l:msvc_debug_link_option,
\        "cmdopt"  : l:msvc_debug_option,
\        "output_encode" : "sjis"
\    })
    
    " msvc リリースビルド
    call g:set_quickrun_config("msvc_release", "msvc_debug", {
\        "exec"   : "%c %o %s:p".l:msvc_release_link_option,
\        "cmdopt" : l:msvc_release_option
\    })

    " msvc プリプロセッサ出力
    call g:set_quickrun_config("msvc_pp", "msvc_debug", {
\        "exec"      : "%c %o %s:p".l:msvc_release_link_option,
\        "cmdopt"    : l:msvc_release_option."/EP ",
\        "outputter" : "buffer"
\    })
    
    call g:set_quickrun_config("g++preprocessor", {}, {
        \ "type"      : "cpp",
        \ "exec"      : "%c %o %s:p ".l:gcc_lib_path,
        \ "command"   : "g++",
        \ "cmdopt"    : include_dirs." -P -E ",
        \ "outputter" : "buffer",
        \ "runner"    : "vimproc"
\    })
    
    let gcc_errorformat = '%*[^"]"%f"%*\D%l:%c: %m,%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l:%c: %m,"%f"%*\D%l: %m,%-G%f:%l: %trror: (Each undeclared identifier is reported only once,%-G%f:%l: %trror: for each function it appears in.),%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %tarning: %m,%f:%l: %m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f",%X%*\a[%*\d]: Leaving directory `%f",%D%*\a: Entering directory `%f",%X%*\a: Leaving directory `%f",%DMaking %*\a in %f'
    
    " g++
    call g:set_quickrun_config("g++", l:quickrun_cpp_default, {
\        "command"   : "g++",
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -Wall",
\    })

    " g++11
    call g:set_quickrun_config("g++11", "g++", {
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x",
\    })

    " g++11-g
    call g:set_quickrun_config("g++11-g", "g++", {
\        "exec"      : "%c %o -g -O0 %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x",
\    })

    " g++4.6.3_11
    call g:set_quickrun_config("g++4.6.3_11", "g++11", {
\        "command"   : "D:/home/gcc/gcc4_6_1/_bin/g++",
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x",
\    })

    " g++4.6.2_11
    call g:set_quickrun_config("g++4.6.2_11", "g++11", {
\        "command"   : "D:/home/gcc/gcc4_6_2/_bin/g++",
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x",
\    })

    " g++4.6.2_11 pedantic
    call g:set_quickrun_config("g++4.6.2_11-pedantic", "g++11", {
\        "command"   : "D:/home/gcc/gcc4_6_2/_bin/g++",
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x -pedantic -pedantic-errors",
\    })
    " g++4.7_11
    call g:set_quickrun_config("g++4.7_11", "g++11", {
\        "command"   : "D:/home/gcc/gcc4_7/_bin/g++",
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x",
\    })

    " g++4.7_11-g
    call g:set_quickrun_config("g++4.7_11-g", "g++4.7_11", {
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -g -std=gnu++0x",
\    })

    " g++4.7_11 pedantic
    call g:set_quickrun_config("g++4.7_11-pedantic", "g++4.7_11", {
\        "exec"      : "%c %o %s -o %s:p:r".l:gcc_lib_path,
\        "cmdopt"    : l:gcc_option." -std=gnu++0x -pedantic -pedantic-errors",
\    })

    " g++11 pedantic
    call g:set_quickrun_config("g++11-pedantic", "g++11", {
\        "cmdopt"    : l:gcc_option." -std=gnu++0x -pedantic -pedantic-errors",
\    })

    " g++11 OpenGL
    call g:set_quickrun_config("g++11-OpenGL", "g++11-pedantic", {
\        "exec"      : "%c %o %s -o %s:p:r"
\            .l:gcc_lib_path." -lglut32 -lglu32 -lopengl32 -lglew32 -lpng -lz ",
\    })

    " g++11 OpenGL-g
    call g:set_quickrun_config("g++11-OpenGL-g", "g++11-pedantic", {
\        "exec"      : "%c %o -g -O0 %s -o %s:p:r"
\            .l:gcc_lib_path." -lglut32 -lglu32 -lopengl32 -lglew32 -lpng -lz ",
\    })

    " g++4.6.3_11
    call g:set_quickrun_config("g++4.6.3_11-OpenGL", "g++4.6.3_11", {
\        "command"   : "D:/home/gcc/gcc4_6_1/_bin/g++",
\        "exec"      : "%c %o %s -o %s:p:r"
\            .l:gcc_lib_path." -lglut32 -lglu32 -lopengl32 -lglew32 ",
\    })

    " g++4.7_11 OpenGL
    call g:set_quickrun_config("g++4.7_11-OpenGL", "g++11-OpenGL", {
\        "command"   : "D:/home/gcc/_bin/g++",
\        "exec"      : "%c %o %s -o %s:p:r"
\            .l:gcc_lib_path." -lglut32 -lglu32 -lopengl32 -lglew32 ",
\    })


    let llvmlibs =
\        " -lLLVMAnalysis".
\        " -lLLVMArchive".
\        " -lLLVMAsmParser".
\        " -lLLVMAsmPrinter".
\        " -lLLVMBitReader".
\        " -lLLVMBitWriter".
\        " -lLLVMCodeGen".
\        " -lLLVMCore".
\        " -lLLVMDebugInfo".
\        " -lLLVMExecutionEngine".
\        " -lLLVMInstCombine".
\        " -lLLVMInstrumentation".
\        " -lLLVMInterpreter".
\        " -lLLVMJIT".
\        " -lLLVMLinker".
\        " -lLLVMMC".
\        " -lLLVMMCDisassembler".
\        " -lLLVMMCJIT".
\        " -lLLVMMCParser".
\        " -lLLVMObject".
\        " -lLLVMRuntimeDyld".
\        " -lLLVMScalarOpts".
\        " -lLLVMSelectionDAG".
\        " -lLLVMSupport".
\        " -lLLVMTableGen".
\        " -lLLVMTarget".
\        " -lLLVMTransformUtils".
\        " -lLLVMVectorize".
\        " -lLLVMX86AsmParser".
\        " -lLLVMX86AsmPrinter".
\        " -lLLVMX86CodeGen".
\        " -lLLVMX86Desc".
\        " -lLLVMX86Disassembler".
\        " -lLLVMX86Info".
\        " -lLLVMX86Utils".
\        " -lLLVMipa".
\        " -lLLVMipo".
\        " -lclangARCMigrate".
\        " -lclangAST".
\        " -lclangAnalysis".
\        " -lclangBasic".
\        " -lclangCodeGen".
\        " -lclangDriver".
\        " -lclangEdit".
\        " -lclangFrontend".
\        " -lclangFrontendTool".
\        " -lclangIndex".
\        " -lclangLex".
\        " -lclangParse".
\        " -lclangRewrite".
\        " -lclangSema".
\        " -lclangSerialization".
\        " -lclangStaticAnalyzerCheckers".
\        " -lclangStaticAnalyzerCore".
\        " -lclangStaticAnalyzerFrontend".
\        " -lgtest".
\        " -lgtest_main".
\        " -lprofile_rt"


    " g++11 clang
    call g:set_quickrun_config("g++11-clang", "g++", {
\        "exec"      : "%c %o %s -o %s:p:r ".l:gcc_lib_path." -LD:/LLVM/BUILD/lib ".llvmlibs,
\        "cmdopt"    : l:gcc_option." -g -std=gnu++0x -ID:/LLVM/BUILD/tools/clang/include -ID:/LLVM/BUILD/include -ID:/LLVM/LLVM/include -ID:/LLVM/LLVM/tools/clang/include -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS",
\    })

    " g++4.7_11 clang
    call g:set_quickrun_config("g++4.7_11-clang", "g++4.7_11", {
\        "exec"      : "%c %o %s -o %s:p:r ".l:gcc_lib_path." -LD:/LLVM/llvm_2_9_release/lib ".llvmlibs,
\        "cmdopt"    : l:gcc_option." -g -std=gnu++0x -ID:/LLVM/llvm_2_9_release/include -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS",
\    })

    " clang++
    let clang_cmd = $LLVM_BIN."/clang++"
    call g:set_quickrun_config("clang++", "g++", {
\        "command" : clang_cmd,
\        "cmdopt"  : l:gcc_option.""
\    })

    " clang++11
    call g:set_quickrun_config("clang++0x", "g++11", {
\        "command" : clang_cmd,
\        "cmdopt"  : l:gcc_option." -std=gnu++0x"
\    })

    " clang++11
    call g:set_quickrun_config("clang++0x-pedantic", "g++11", {
\        "command" : clang_cmd,
\        "cmdopt"  : l:gcc_option." -std=gnu++0x -pedantic -pedantic-errors",
\    })

    " clang++11-2.9
    call g:set_quickrun_config("clang++2.9", "clang++0x", {
\        "command"   : "D:/LLVM/BUILD_2_9/bin/clang++",
\    })
    
    " clang++11-3.0
    call g:set_quickrun_config("clang++3.0", "clang++0x", {
\        "command"   : "D:/LLVM/BUILD_3_0/bin/clang++",
\    })
    
    " clang++11-gcc4.7
    call g:set_quickrun_config("clang-gcc4.7", "clang++0x", {
\        "command"   : "D:/LLVM/BUILD_gcc_4_7/bin/clang++",
\    })

    " CppCheck
    let cppcheck_command = "D:/home/work/software/lib/cpp/cppcheck/cli/release/cppcheck.exe"
    let g:quickrun_config["CppCheck"] = {
        \ "type" : "",
        \ "exec"      : "%c %o %s:p ",
        \ "command" : cppcheck_command,
        \ "cmdopt"  : "--enable=all",
        \ "outputter" : "buffer",
        \ "runner" : "vimproc",
        \}

    " Cinder
    call g:set_quickrun_config("cinder", "msvc_debug", {
\        "cmdopt"  :
\            "/nologo /W3 /WX- /Od /Ob1 /Oy- /DWIN32".
\            "/D_DEBUG /D_WINDOWS /D_UNICODE /DUNICODE ".
\            "/Gm /Zi /EHsc /RTC1 /MTd /GS ".include_dirs,
\        "exec"    : "%c %o %s:p "
\            .l:msvc_debug_link_option
\            ." -LIBPATH:".$CINDER_ROOT."/lib "
\            ." -LIBPATH:".$CINDER_ROOT."/lib/msw "
\            ." cinder_d.lib "
\            ." /NODEFAULTLIB:LIBCMT ",
\        "output_encode" : "sjis"
\    })
endfunction

call g:update_compiler_option()
" }}}


" デフォルトの設定
let g:quickrun_compile_command.cpp = "msvc_debug"


" BOOST_PP を消す
autocmd Filetype cpp call <SID>boost_pp_syntax()
function! s:boost_pp_syntax()
    if exists("b:boost_pp_syntax")
        return
    endif
    let b:boost_pp_syntax=1
    syntax match boost_pp /BOOST_PP_/ transparent conceal cchar=_
    syntax match pp /\<PP_/ transparent conceal cchar=_
    
    " 速度が気になる場合は、以下をコメントアウト
    " ---- ここから ----
    " let i = 0
    " let a_z = "abcdefghijklmnopqrstuvwxyz"
    " while i < strlen(a_z)
    "     let c = a_z[i]
    "     " execute "syntax match boost_pp_".c." /".toupper(c)."/".
    "     "     \ " transparent conceal cchar=".c
    "     execute "syntax match ".c." /".toupper(c).
    "         \ "/ contains=boost_pp,pp transparent conceal cchar=".c
    "     let i += 1
    " endwhile
    " transparentsyntax match boost_pp /BOOST_PP_/ transparent conceal cchar=_
    " syntax match pp /\<PP_/ transparent conceal cchar=_
    " ---- ここまで ----
    
    " おまけ、[] を λで表示
    " パースは適当
    syntax match lambda /[[]]/ transparent conceal cchar=λ
    
    " mpl::string の表記を見やすく
    syntax match mpl_string /'\s*,\s*'\ze.*'\s*>/ transparent conceal
    
"    set conceallevel=2
    
    " Boost.Phoenix のエラーを見やすくしてみたり。
    syntax match boost_phoenix /boost::phoenix/ transparent conceal cchar=p
    syntax match boost_proto /boost::proto/ transparent conceal cchar=e
    
endfunction


" filetype = cpp の時
autocmd FileType cpp call s:cpp_loaded()
function! s:cpp_loaded()
    set nocindent
    setlocal matchpairs+=<:>

    if !exists("g:neocomplcache_include_paths")
        let g:neocomplcache_include_paths ={}
    endif
    let g:neocomplcache_source_disable['include_complete']=1
endfunction


" mpl::string を整形
nnoremap <silent> <Space><Space>s :BoostMPLStringSlice1<CR>:BoostMPLStringSlice2<CR>

command!
    \ -nargs=* BoostMPLStringSlice1
    \ execute "normal! di'"
command!
    \ -nargs=* BoostMPLStringSlice2
    \ execute "normal! i".s:slice(getreg("*"))

function! s:slice(str)
    let l:result = join(split(a:str, '.\{,4}\zs'), "','")
    return l:result
endfunction


" プリプロセスの出力を整形
command!
    \ -nargs=* PreproseccorOutputReplace
    \ :%s/;\zs\s*/\r\r/g|
    \ :%s/^\@!\s*\zestruct/\r/g|:noh


" シンタックスチェック用の quickrun.vim のコンフィグ {{{
" gcc 版
let g:quickrun_config["CppSyntaxCheck_gcc"] = {
    \ "type"  : "cpp_",
    \ "exec"      : "%c %o %s:p ",
    \ "command"   : "D:/home/gcc/gcc4_7/_bin/g++",
    \ "cmdopt"    : "-fsyntax-only -std=gnu++0x -Wall ".g:get_include_dirs_option(),
    \ "outputter" : "static_syntax_check_location_list",
    \ "runner"    : "vimproc",
    \ "outputter/static_syntax_check_location_list/errorformat" : "%f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m"
\ }


function! s:is_cpp_comple_error_opened()
    return count(map(map(range(1, winnr("$")), "winbufnr(v:val)"), "bufname(v:val)"),
    \    "[unite] - cpp-compile-error@1"
    \)
endfunction

function! s:static_syntax_check()
    if get(g:, "cpp_use_static_syntax_check", 0)
        :QuickRun CppSyntaxCheck_gcc
    endif
endfunction

augroup CPP
    autocmd!
    autocmd BufWritePost *.cpp,*.h,*.hpp :call <SID>static_syntax_check()
augroup END

" }}}

" 使用する msvc を設定 {{{
let $VSINSTALLDIR="C:/Program Files/Microsoft Visual Studio 10.0"
let $VCINSTALLDIR=$VSINSTALLDIR."/VC"

let $DevEnvDir=$VSINSTALLDIR."/Common7/IDE;"
"let $PATH=$FrameworkDir.$Framework35Version.";".$PATH
"let $PATH=$FrameworkDir.$FrameworkVersion.";".$PATH
let $PATH=$VSINSTALLDIR."Common7/Tools;".$PATH
let $PATH=$VCINSTALLDIR."/bin;".$PATH
let $PATH=$DevEnvDir.";".$PATH

let $INCLUDE=$VCINSTALLDIR."/include;".$INCLUDE
let $LIB=$VCINSTALLDIR."/LIB;".$LIB
let $LIBPATH=$VCINSTALLDIR."/LIB;".$LIBPATH

" Windows SDK(or Platform SDK?)
let $WindowsSdkDir="C:/Program Files/Microsoft SDKs/Windows/v7.1"
"let $WindowsSdkDir="C:/Program Files/Microsoft Platform SDK"
let $INCLUDE=$WindowsSdkDir."/include;".$INCLUDE
let $LIB=$WindowsSdkDir."/lib;".$LIB
" }}}

" }}}


" }}}

" vim:set foldmethod=marker:

[bundles.vim]

neobundle の設定だけは起動時に :source する事があるので別ファイルにしています。

" スタンダード
NeoBundle 'git://github.com/Shougo/vimfiler.git'
NeoBundle 'git://github.com/Shougo/vimshell.git'
NeoBundle "git://github.com/Shougo/vimproc.git"

NeoBundle "git://github.com/Shougo/unite.vim.git"
NeoBundle "git://github.com/Shougo/neocomplcache.git"
NeoBundle "git://github.com/Shougo/neocomplcache-snippets-complete.git"

" Twitter
NeoBundle "git://github.com/basyura/TweetVim.git"
NeoBundle "git://github.com/basyura/twibill.vim.git"
NeoBundle "git://github.com/basyura/bitly.vim.git"
NeoBundle "git://github.com/basyura/webapi-vim.git"

" C++
NeoBundle "git://github.com/osyo-manga/neocomplcache-clang_complete.git"
NeoBundle "git://github.com/Rip-Rip/clang_complete.git"

" Dart
NeoBundle "git://github.com/vim-scripts/Dart.git"

" Haskell
NeoBundle "git://github.com/eagletmt/unite-haddock.git"
NeoBundle "git://github.com/ujihisa/neco-ghc.git"
NeoBundle "git://github.com/eagletmt/ghcmod-vim.git"

" F#
NeoBundle "git://github.com/kongo2002/fsharp-vim.git"

" コーディング支援
NeoBundle "git://github.com/scrooloose/syntastic.git"
NeoBundle "git://github.com/h1mesuke/unite-outline.git"
NeoBundle "git://github.com/tyru/caw.vim.git"
NeoBundle "git://github.com/LStinson/TagmaTips.git"
NeoBundle "git://github.com/vim-scripts/Highlight-UnMatched-Brackets.git"
NeoBundle "git://github.com/dannyob/quickfixstatus.git"
NeoBundle "git://github.com/taku-o/vim-toggle.git"

" テキスト支援
NeoBundle "git://github.com/tpope/vim-surround.git"

" colorscheme
NeoBundle "git://github.com/altercation/vim-colors-solarized.git"
NeoBundle "git://github.com/tomasr/molokai.git"
NeoBundle "git://github.com/zefei/simple-dark.git"
NeoBundle "git://github.com/molok/vim-vombato-colorscheme.git"
NeoBundle "https://github.com/larssmit/vim-getafe"
NeoBundle "git://github.com/shawncplus/skittles_berry.git"
NeoBundle "git://github.com/depuracao/vim-darkdevel.git"

" Vim