Created
March 21, 2013 13:54
-
-
Save Koki-Shimizu/5213162 to your computer and use it in GitHub Desktop.
This is my vim setting file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" neobundle"{{{ | |
filetype plugin indent off " required! | |
" initialize"{{{ | |
if has('vim_starting') | |
let bundle_dir = '~/.bundle' | |
if !isdirectory(bundle_dir.'/neobundle.vim') | |
call system( 'git clone https://github.com/Shougo/neobundle.vim.git '.bundle_dir.'/neobundle.vim') | |
endif | |
exe 'set runtimepath+='.bundle_dir.'/neobundle.vim' | |
call neobundle#rc(bundle_dir) | |
endif | |
augroup MyNeobundle | |
au! | |
au Syntax vim syntax keyword vimCommand NeoBundle NeoBundleLazy NeoBundleSource NeoBundleFetch | |
augroup END | |
"}}} | |
" 暫定customize {{{ | |
function! Neo_al(ft) "{{{ | |
return { 'autoload' : { | |
\ 'filetype' : a:ft | |
\ }} | |
endfunction"}}} | |
function! Neo_operator(mappings) "{{{ | |
return { | |
\ 'depends' : 'kana/vim-textobj-user', | |
\ 'autoload' : { | |
\ 'mappings' : a:mappings | |
\ }} | |
endfunction"}}} | |
function! BundleLoadDepends(bundle_names) "{{{ | |
if !exists('g:loaded_bundles') | |
let g:loaded_bundles = {} | |
endif | |
" bundleの読み込み | |
if !has_key( g:loaded_bundles, a:bundle_names ) | |
execute 'NeoBundleSource '.a:bundle_names | |
let g:loaded_bundles[a:bundle_names] = 1 | |
endif | |
endfunction"}}} | |
"}}} | |
" コマンドを伴うやつの遅延読み込み | |
function! BundleWithCmd(bundle_names, cmd) "{{{ | |
call BundleLoadDepends(a:bundle_names) | |
" コマンドの実行 | |
if !empty(a:cmd) | |
execute a:cmd | |
endif | |
endfunction "}}} | |
"bundle"{{{ | |
" その他 {{{ | |
NeoBundle 'Shougo/vimproc', { | |
\ 'build' : { | |
\ 'mac' : 'make -f make_mac.mak', | |
\ 'unix' : 'make -f make_unix.mak', | |
\ }, | |
\ } | |
NeoBundleLazy 'taichouchou2/vim-endwise.git', { | |
\ 'autoload' : { | |
\ 'insert' : 1, | |
\ } } | |
" }}} | |
" 補完 {{{ | |
NeoBundleLazy 'Shougo/neocomplcache', { | |
\ 'autoload' : { | |
\ 'insert' : 1, | |
\ }} | |
NeoBundleLazy 'Shougo/neosnippet', { | |
\ 'autoload' : { | |
\ 'insert' : 1, | |
\ }} | |
NeoBundle 'Shougo/neocomplcache-rsense', { | |
\ 'depends': 'Shougo/neocomplcache', | |
\ 'autoload': { 'filetypes': 'ruby' }} | |
NeoBundleLazy 'taichouchou2/rsense-0.3', { | |
\ 'build' : { | |
\ 'mac': 'ruby etc/config.rb > ~/.rsense', | |
\ 'unix': 'ruby etc/config.rb > ~/.rsense', | |
\ } } | |
" }}} | |
" 便利 {{{ | |
" 範囲指定のコマンドが使えないので、tcommentのLazy化はNeoBundleのアップデートを待ちましょう... | |
NeoBundle 'tomtom/tcomment_vim' | |
NeoBundleLazy 'tpope/vim-surround', { | |
\ 'autoload' : { | |
\ 'mappings' : [ | |
\ ['nx', '<Plug>Dsurround'], ['nx', '<Plug>Csurround'], | |
\ ['nx', '<Plug>Ysurround'], ['nx', '<Plug>YSurround'], | |
\ ['nx', '<Plug>Yssurround'], ['nx', '<Plug>YSsurround'], | |
\ ['nx', '<Plug>YSsurround'], ['vx', '<Plug>VgSurround'], | |
\ ['vx', '<Plug>VSurround'] | |
\ ]}} | |
" }}} | |
" ruby / railsサポート {{{ | |
NeoBundle 'tpope/vim-rails' | |
NeoBundleLazy 'ujihisa/unite-rake', { | |
\ 'depends' : 'Shougo/unite.vim' } | |
NeoBundleLazy 'basyura/unite-rails', { | |
\ 'depends' : 'Shjkougo/unite.vim' } | |
NeoBundleLazy 'taichouchou2/unite-rails_best_practices', { | |
\ 'depends' : 'Shougo/unite.vim', | |
\ 'build' : { | |
\ 'mac': 'gem install rails_best_practices', | |
\ 'unix': 'gem install rails_best_practices', | |
\ } | |
\ } | |
NeoBundleLazy 'taichouchou2/unite-reek', { | |
\ 'build' : { | |
\ 'mac': 'gem install reek', | |
\ 'unix': 'gem install reek', | |
\ }, | |
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] }, | |
\ 'depends' : 'Shougo/unite.vim' } | |
NeoBundleLazy 'taichouchou2/alpaca_complete', { | |
\ 'depends' : 'tpope/vim-rails', | |
\ 'build' : { | |
\ 'mac': 'gem install alpaca_complete', | |
\ 'unix': 'gem install alpaca_complete', | |
\ } | |
\ } | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
" plugin management | |
Bundle 'gmarik/vundle' | |
" Tree Display plugin for mainly RoR | |
Bundle 'scrooloose/nerdtree' | |
Bundle 'scrooloose/nerdcommenter' | |
" Ruby plugin | |
Bundle 'vim-ruby/vim-ruby' | |
" git plugin | |
Bundle 'tpope/vim-fugitive' | |
let s:bundle_rails = 'unite-rails unite-rails_best_practices unite-rake alpaca_complete' | |
function! s:bundleLoadDepends(bundle_names) "{{{ | |
" bundleの読み込み | |
execute 'NeoBundleSource '.a:bundle_names | |
au! MyAutoCmd | |
endfunction"}}} | |
aug MyAutoCmd | |
au User Rails call <SID>bundleLoadDepends(s:bundle_rails) | |
aug END | |
" reference環境 | |
NeoBundleLazy 'vim-ruby/vim-ruby', { | |
\ 'autoload' : { 'filetypes': ['ruby', 'eruby', 'haml'] } } | |
NeoBundleLazy 'taka84u9/vim-ref-ri', { | |
\ 'depends': ['Shougo/unite.vim', 'thinca/vim-ref'], | |
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } } | |
NeoBundleLazy 'skwp/vim-rspec', { | |
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } } | |
NeoBundleLazy 'ruby-matchit', { | |
\ 'autoload' : { 'filetypes': ['ruby', 'eruby', 'haml'] } } | |
" }}} | |
" }}} | |
" Installation check. "{{{ | |
if neobundle#exists_not_installed_bundles() | |
echomsg 'Not installed bundles : ' . | |
\ string(neobundle#get_not_installed_bundle_names()) | |
echomsg 'Install Plugins' | |
NeoBundleInstall | |
endif | |
"}}} | |
filetype plugin indent on | |
"}}} | |
" plugin settings"{{{ | |
"------------------------------------ | |
" endwise.vim | |
"------------------------------------ | |
"{{{ | |
let g:endwise_no_mappings=1 | |
"}}} | |
"------------------------------------ | |
" vim-surround | |
"------------------------------------ | |
" {{{ | |
nmap ds <Plug>Dsurround | |
nmap cs <Plug>Csurround | |
nmap ys <Plug>Ysurround | |
nmap yS <Plug>YSurround | |
nmap yss <Plug>Yssurround | |
nmap ySs <Plug>YSsurround | |
nmap ySS <Plug>YSsurround | |
xmap S <Plug>VSurround | |
xmap gS <Plug>VgSurround | |
vmap s <Plug>VSurround | |
" surround_custom_mappings.vim"{{{ | |
let g:surround_custom_mapping = {} | |
let g:surround_custom_mapping._ = { | |
\ 'p': "<pre> \r </pre>", | |
\ 'w': "%w(\r)", | |
\ } | |
let g:surround_custom_mapping.help = { | |
\ 'p': "> \r <", | |
\ } | |
let g:surround_custom_mapping.ruby = { | |
\ '-': "<% \r %>", | |
\ '=': "<%= \r %>", | |
\ '9': "(\r)", | |
\ '5': "%(\r)", | |
\ '%': "%(\r)", | |
\ 'w': "%w(\r)", | |
\ '#': "#{\r}", | |
\ '3': "#{\r}", | |
\ 'e': "begin \r end", | |
\ 'E': "<<EOS \r EOS", | |
\ 'i': "if \1if\1 \r end", | |
\ 'u': "unless \1unless\1 \r end", | |
\ 'c': "class \1class\1 \r end", | |
\ 'm': "module \1module\1 \r end", | |
\ 'd': "def \1def\1\2args\r..*\r(&)\2 \r end", | |
\ 'p': "\1method\1 do \2args\r..*\r|&| \2\r end", | |
\ 'P': "\1method\1 {\2args\r..*\r|&|\2 \r }", | |
\ } | |
let g:surround_custom_mapping.javascript = { | |
\ 'f': "function(){ \r }" | |
\ } | |
let g:surround_custom_mapping.lua = { | |
\ 'f': "function(){ \r }" | |
\ } | |
let g:surround_custom_mapping.python = { | |
\ 'p': "print( \r)", | |
\ '[': "[\r]", | |
\ } | |
let g:surround_custom_mapping.vim= { | |
\'f': "function! \r endfunction" | |
\ } | |
"}}} | |
"}}} | |
"------------------------------------ | |
" neocomplcache | |
"------------------------------------ | |
" 補完・履歴 neocomplcache "{{{ | |
set infercase | |
"---------------------------------------- | |
" neocomplcache | |
let g:neocomplcache_enable_at_startup = 1 | |
" default config"{{{ | |
let g:neocomplcache_force_overwrite_completefunc = 1 | |
let g:neocomplcache#sources#rsense#home_directory = expand('~/.bundle/rsense-0.3') | |
let g:neocomplcache_enable_camel_case_completion = 1 | |
let g:neocomplcache_enable_underbar_completion = 1 | |
let g:neocomplcache_skip_auto_completion_time = '0.3' | |
"}}} | |
" keymap {{{ | |
imap <expr><C-g> neocomplcache#undo_completion() | |
imap <expr><CR> neocomplcache#smart_close_popup() . "<CR>" . "<Plug>DiscretionaryEnd" | |
imap <silent><expr><S-TAB> pumvisible() ? "\<C-P>" : "\<S-TAB>" | |
" imap <silent><expr><TAB> pumvisible() ? "\<C-N>" : "\<TAB>" | |
imap <expr><TAB> neosnippet#expandable() ? "\<Plug>(neosnippet_jump_or_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>" | |
" }}} | |
"}}} | |
"------------------------------------ | |
" neosnippet | |
"------------------------------------ | |
" neosnippet "{{{ | |
" snippetを保存するディレクトリを設定してください | |
" example | |
" let s:default_snippet = neobundle#get_neobundle_dir() . '/neosnippet/autoload/neosnippet/snippets' " 本体に入っているsnippet | |
" let s:my_snippet = '~/snippet' " 自分のsnippet | |
" let g:neosnippet#snippets_directory = s:my_snippet | |
" let g:neosnippet#snippets_directory = s:default_snippet . ',' . s:my_snippet | |
imap <silent><C-F> <Plug>(neosnippet_expand_or_jump) | |
inoremap <silent><C-U> <ESC>:<C-U>Unite snippet<CR> | |
nnoremap <silent><Space>e :<C-U>NeoSnippetEdit -split<CR> | |
smap <silent><C-F> <Plug>(neosnippet_expand_or_jump) | |
" xmap <silent>o <Plug>(neosnippet_register_oneshot_snippet) | |
"}}} | |
"------------------------------------ | |
" vim-rails | |
"------------------------------------ | |
""{{{ | |
"有効化 | |
let g:rails_default_file='config/database.yml' | |
let g:rails_level = 4 | |
let g:rails_mappings=1 | |
let g:rails_modelines=0 | |
" let g:rails_some_option = 1 | |
" let g:rails_statusline = 1 | |
" let g:rails_subversion=0 | |
" let g:rails_syntax = 1 | |
" let g:rails_url='http://localhost:3000' | |
" let g:rails_ctags_arguments='--languages=-javascript' | |
" let g:rails_ctags_arguments = '' | |
function! SetUpRailsSetting() | |
nnoremap <buffer><Space>r :R<CR> | |
nnoremap <buffer><Space>a :A<CR> | |
nnoremap <buffer><Space>m :Rmodel<Space> | |
nnoremap <buffer><Space>c :Rcontroller<Space> | |
nnoremap <buffer><Space>v :Rview<Space> | |
nnoremap <buffer><Space>p :Rpreview<CR> | |
endfunction | |
aug MyAutoCmd | |
au User Rails call SetUpRailsSetting() | |
aug END | |
aug RailsDictSetting | |
au! | |
aug END | |
"}}} | |
"------------------------------------ | |
" Unite-rails.vim | |
"------------------------------------ | |
"{{{ | |
function! UniteRailsSetting() | |
nnoremap <buffer><C-H><C-H><C-H> :<C-U>Unite rails/view<CR> | |
nnoremap <buffer><C-H><C-H> :<C-U>Unite rails/model<CR> | |
nnoremap <buffer><C-H> :<C-U>Unite rails/controller<CR> | |
nnoremap <buffer><C-H>c :<C-U>Unite rails/config<CR> | |
nnoremap <buffer><C-H>s :<C-U>Unite rails/spec<CR> | |
nnoremap <buffer><C-H>m :<C-U>Unite rails/db -input=migrate<CR> | |
nnoremap <buffer><C-H>l :<C-U>Unite rails/lib<CR> | |
nnoremap <buffer><expr><C-H>g ':e '.b:rails_root.'/Gemfile<CR>' | |
nnoremap <buffer><expr><C-H>r ':e '.b:rails_root.'/config/routes.rb<CR>' | |
nnoremap <buffer><expr><C-H>se ':e '.b:rails_root.'/db/seeds.rb<CR>' | |
nnoremap <buffer><C-H>ra :<C-U>Unite rails/rake<CR> | |
nnoremap <buffer><C-H>h :<C-U>Unite rails/heroku<CR> | |
endfunction | |
aug MyAutoCmd | |
au User Rails call UniteRailsSetting() | |
aug END | |
"}}} | |
"---------------------------------------- | |
" vim-ref | |
"---------------------------------------- | |
"{{{ | |
let g:ref_open = 'split' | |
let g:ref_refe_cmd = expand('~/.vim/ref/ruby-ref1.9.2/refe-1_9_2') | |
nnoremap rr :<C-U>Unite ref/refe -default-action=split -input= | |
nnoremap ri :<C-U>Unite ref/ri -default-action=split -input= | |
aug MyAutoCmd | |
au FileType ruby,eruby,ruby.rspec nnoremap <silent><buffer>KK :<C-U>Unite -no-start-insert ref/ri -input=<C-R><C-W><CR> | |
au FileType ruby,eruby,ruby.rspec nnoremap <silent><buffer>K :<C-U>Unite -no-start-insert ref/refe -input=<C-R><C-W><CR> | |
aug END | |
"}}} | |
"------------------------------------ | |
" Unite-reek, Unite-rails_best_practices | |
"------------------------------------ | |
" {{{ | |
nnoremap <silent> [unite]<C-R> :<C-u>Unite -no-quit reek<CR> | |
nnoremap <silent> [unite]<C-R><C-R> :<C-u>Unite -no-quit rails_best_practices<CR> | |
" }}} | |
"}}} | |
" | |
"========================== | |
"vim settings | |
"========================== | |
"カラースキーマを設定 | |
colorscheme BlackSea | |
"新しい行のインデントを現在行と同じにする | |
set autoindent | |
"バックアップファイルを作るディレクトリ | |
set backupdir=$HOME/vimbackup | |
"ファイル保存ダイアログの初期ディレクトリをバッファファイル位置に設定 | |
set browsedir=buffer | |
"クリップボードをWindowsと連携 | |
set clipboard=unnamed | |
"スワップファイル用のディレクトリ | |
set directory=$HOME/vimbackup | |
"タブの代わりに空白文字を挿入する | |
set expandtab | |
"変更中のファイルでも、保存しないで他のファイルを表示 | |
set hidden | |
"インクリメンタルサーチを行う | |
set incsearch | |
"タブ文字、行末など不可視文字を表示する | |
set list | |
"listで表示される文字のフォーマットを指定する | |
set listchars=eol:$,tab:>\ ,extends:< | |
"行番号を表示する | |
set number | |
"シフト移動幅 | |
set shiftwidth=4 | |
"閉じ括弧が入力されたとき、対応する括弧を表示する | |
set showmatch | |
"検索時に大文字を含んでいたら大/小を区別 | |
set smartcase | |
"新しい行を作ったときに高度な自動インデントを行う | |
set smartindent | |
"行頭の余白内で Tab を打ち込むと、'shiftwidth' の数だけインデントする。 | |
set smarttab | |
"ファイル内の <Tab> が対応する空白の数 | |
set tabstop=4 | |
"カーソルを行頭、行末で止まらないようにする | |
set whichwrap=b,s,h,l,<,>,[,] | |
"検索をファイルの先頭へループしない | |
set nowrapscan | |
"入力モード時、ステータスラインのカラーを変更 | |
augroup InsertHook | |
autocmd! | |
autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340 | |
autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90 | |
augroup END | |
"日本語入力をリセット | |
au BufNewFile,BufRead * set iminsert=0 | |
"タブ幅をリセット | |
au BufNewFile,BufRead * set tabstop=4 shiftwidth=4 | |
".txtファイルで自動的に日本語入力ON | |
au BufNewFile,BufRead *.txt set iminsert=2 | |
".rhtmlと.rbでタブ幅を変更 | |
au BufNewFile,BufRead *.rhtml set nowrap tabstop=2 shiftwidth=2 | |
au BufNewFile,BufRead *.rb set nowrap tabstop=2 shiftwidth=2 | |
"全角スペースを視覚化 | |
highlight ZenkakuSpace cterm=underline ctermfg=lightblue guibg=#666666 | |
au BufNewFile,BufRead * match ZenkakuSpace / / | |
"========================== | |
"neocomplecache | |
"========================== | |
let g:acp_enableAtStartup = 0 "AutoComplPopを無効化 | |
let g:neocomplcache_enable_at_startup = 1 "neocomplcacheを起動時に有効化 | |
" let g:neocomplcache_enable_smart_case = 1 "大文字小文字を区別しない | |
"let g:neocomplcache_enable_camel_case_completion= 1 "camel caseを有効化。大文字を区切りとしたワイルドカードみたいなもの | |
let g:neocomplcache_enable_underbar_completion= 1 " _の補完を有効にする | |
let g:neocomplcache_min_syntax_length = 3 " シンタックスをキャッシュするときの最小文字長 | |
let g:neocomplcache_lock_buffer_name_pattern= '\*ku\*' "neocomplcacheを自動的にロックするバッファ名のパターン | |
"========================== | |
"NERD Tree | |
"========================== | |
let g:NERDChristmasTree=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment