/
vimrc
435 lines (378 loc) · 12.9 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
" -------------------
" encoding
" -------------------
"enc/fencs/ffs
set encoding=utf-8
set fileencodings=utf-8,cp932,eucjp,iso2022jp
set fileformats=unix,dos,mac
scriptencoding utf-8
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
if $GOROOT != ''
set rtp+=$GOROOT/misc/vim
endif
" -------------------
" Vundle
" -------------------
Plugin 'gmarik/Vundle.vim'
"misc
Plugin 'clones/vim-l9'
Plugin 'FuzzyFinder'
Plugin 'Shougo/neocomplcache'
Plugin 'Shougo/neosnippet'
"Plugin 'Shougo/vimfiler'
"Plugin 'Shougo/vimshell'
"Plugin 'Shougo/vimproc'
Plugin 'thinca/vim-quickrun'
Plugin 'thinca/vim-ambicmd'
Plugin 'surround.vim'
Plugin 'css_color.vim'
"Plugin 'mattn/zencoding-vim'
Plugin 'mattn/emmet-vim'
"Plugin 'mattn/flappyvird-vim'
"Plugin 'nathanaelkane/vim-indent-guides'
"Plugin 'project.tar.gz'
"Plugin 'unite.vim'
Plugin 'vim-jp/vimdoc-ja'
"Plugin 'Source-Explorer-srcexpl.vim'
"Plugin 'trinity.vim'
"Plugin 'taglist.vim'
"Plugin 'The-NERD-tree'
Plugin 'scrooloose/syntastic'
"colorscheme
"Plugin 'billw.vim'
"ruby
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-cucumber'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-rails'
Plugin 'astashov/vim-ruby-debugger'
"js
Plugin 'JavaScript-syntax'
Plugin 'itspriddle/vim-javascript-indent'
Plugin 'kchmck/vim-coffee-script'
"git
"Plugin 'motemen/git-vim'
"Plugin 'tpope/vim-fugitive'
call vundle#end()
filetype indent plugin on
" -------------------
" color
" -------------------
syntax on
highlight LineNr ctermfg=lightgrey " 行番号
highlight NonText ctermfg=darkgrey
highlight Folded ctermfg=blue
highlight SpecialKey cterm=underline ctermfg=darkgrey " 特殊記号
highlight StatusLine term=NONE cterm=NONE ctermfg=black ctermbg=white
highlight TabLine cterm=NONE ctermfg=black ctermbg=white
highlight TabLineSel cterm=bold ctermfg=white ctermbg=black
highlight TabLineFill ctermfg=white
"highlight Search ctermbg=red
highlight Search ctermfg=white ctermbg=magenta
" ポップアップの配色
highlight Pmenu ctermbg=darkblue
highlight PmenuSel ctermbg=darkred
highlight PmenuSbar ctermbg=darkblue
" disable bold font
"if !has('gui_running')
" set t_Co=8 t_md=
"endif
" -------------------
" 基本設定
" -------------------
set ambiwidth=double " 記号(※とか△とか)入力時にカーソルがズレないように設定
set autoindent
set autoread " 外部のエディタで編集中のファイルが変更されたら再読み込み
set backspace=indent,eol,start
set backupskip=/tmp/*,/private/tmp/*
"set backupdir=~/.Trash
set clipboard+=autoselect " visual selection -> clipboard
set clipboard+=unnamed " yank -> clipboard
set complete+=k " 辞書ファイルからの単語補完
set cursorline
set display=lastline
set foldmethod=syntax
set foldlevel=100
set formatoptions+=r
set helplang=en,ja
set hidden
set laststatus=2
set list
set listchars=tab:▸\
"set listchars=tab:>-,trail:-,nbsp:%,extends:>,precedes:<
set mouse=a
set nobackup
set noexpandtab " tab -> space 置換なし
set number
set ruler
set showcmd
set showmatch " 対応する括弧を表示
set smartindent
set suffixes=.bak,~,.swp
set tabstop=4 shiftwidth=4
set ttimeoutlen=0
set virtualedit=block
set visualbell t_vb= " no beep
set wildmode=list,full " コマンドライン補完
" -------------------
" ステータスライン
" -------------------
"set statusline=%y%{GetStatusEx()}%F%m%r%=<%c:%l>
set statusline=%y%<%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%f%m%r%h%w%=<%l,%c%V>%6p%%
"set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%=%l,%c%v%8p
" -------------------
" 補完
" -------------------
set wildmode=list:longest,list:full " list:longest 複数あれば全て羅列・共通最長まで補完
" list:full 複数あれば全て羅列・最初のマッチのマッチを補完
" -------------------
" 検索
" -------------------
set hlsearch " ハイライト
"set nohlsearch
set ignorecase " 大文字小文字区別無し
set incsearch " インクリメンタルサーチ
set smartcase " 大文字が含まれていれば区別して検索
" -------------------
" mapping
" -------------------
"noremap ; :
"noremap : ;
"nnoremap + <C-w>+
"nnoremap _ <C-w>-
nnoremap <M-h> <C-w>h
nnoremap <M-j> <C-w>j
nnoremap <M-k> <C-w>k
nnoremap <M-l> <C-w>l
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-h> <Left>
inoremap <C-l> <Right>
nnoremap <C-p> :set paste<CR>i
"nnoremap <S-p> :set paste<CR>i
nmap <silent> <C-N> :noh<CR>
inoremap <silent> jj <ESC>
"補完
"inoremap <C-o> <C-x><C-o>
"inoremap { {}<LEFT>
"inoremap [ []<LEFT>
"inoremap ( ()<LEFT>
"inoremap <silent> <C-p> <Space>=> <RIGHT>
"Buffer
nmap <Space>b :ls<CR>:buffer
nmap <Space>f :edit .<CR>
nmap <Space>v :vsplit<CR><C-w><C-w>:ls<CR>:buffer
nmap <Space>V :Vexplore!<CR><CR>
"Tabs
"nnoremap <Space>t t
"nnoremap <Space>T T
"nnoremap t <Nop>
nnoremap <silent> tc :<C-u>tabnew<CR>:tabmove<CR>
nnoremap <silent> tk :<C-u>tabclose<CR>
nnoremap <silent> tn :<C-u>tabnext<CR>
nnoremap <silent> tp :<C-u>tabprevious<CR>
"fuzzyfinder
"nnoremap <Space>f f
"nnoremap <Space>F F
"nnoremap f <Nop>
nnoremap <unique> <silent> fb :<C-u>FufBuffer!<CR>
nnoremap <unique> <silent> ff :<C-u>FufFile! <C-r>=expand('%:~:.')[:-1-len(expand('%:~:.:t'))]<CR><CR>
nnoremap <unique> <silent> <C-t> :<C-u>FufFile! <C-r>=expand('%:~:.')[:-1-len(expand('%:~:.:t'))]<CR><CR>
nnoremap <unique> <silent> fm :<C-u>FufMruFile!<CR>
nnoremap <unique> <silent> tb :<C-u>tabnew<CR>:tabmove<CR>:FufBuffer!<CR>
nnoremap <unique> <silent> tf :<C-u>tabnew<CR>:tabmove<CR>:FufFile! <C-r>=expand('#:~:.')[:-1-len(expand('#:~:.:t'))]<CR><CR>
nnoremap <unique> <silent> tm :<C-u>tabnew<CR>:tabmove<CR>:FufMruFile!<CR>
"ctags
nnoremap <C-]><C-]> <C-t>
"rails-vim
nnoremap :rv :Rview<CR>
nnoremap :rc :Rcontroller<CR>
nnoremap :rs :Rspec<CR>
nnoremap :rm :Rmodel<CR>
"java
:let java_highlight_all=1
:let java_highlight_debug=1
:let java_space_errors=1
:let java_highlight_functions=1
augroup MyAutoCmd
autocmd!
autocmd FileType c,cpp,perl,sh,vim,conf set ts=4 sw=4 expandtab
autocmd FileType java set ts=2 sw=2 expandtab
autocmd FileType python set ts=4 sw=4 expandtab
autocmd FileType ruby,eruby,cucumber set nowrap ts=2 sw=2 expandtab
autocmd FileType html set ts=2 sw=2 expandtab ft=xhtml
autocmd FileType javascript,coffee set ts=2 sw=2 expandtab
autocmd FileType yaml set nowrap ts=2 sw=2 expandtab
autocmd BufNewFile,BufRead *.js set ft=javascript
autocmd BufNewFile,BufRead *.java set ft=java
autocmd BufNewFile,BufRead *.ejs set ft=html
"rails
autocmd BufNewFile,BufRead app/**/*.rhtml set fenc=utf-8
autocmd BufNewFile,BufRead app/**/*.erb set fenc=utf-8
autocmd BufNewFile,BufRead app/**/*.haml set fenc=utf-8
autocmd BufNewFile,BufRead app/**/*.rb set fenc=utf-8
"go
" 保存時に :Fmt する
autocmd BufWritePre *.go Fmt
autocmd BufNewFile,BufRead *.go set sw=4 noexpandtab ts=4
autocmd FileType go compiler go
" 相対パスを設定
autocmd FileType html setlocal includeexpr=substitute(v:fname,'^\\/','','') | setlocal path+=;/
"Insert mode抜けたら nopaste
autocmd InsertLeave * set nopaste
"自動的に QuickFix リストを表示する
autocmd QuickFixCmdPost make,grep,grepadd,vimgrep,vimgrepadd cwin
autocmd QuickFixCmdPost lmake,lgrep,lgrepadd,lvimgrep,lvimgrepadd lwin
"前回表示位置を記憶
"autocmd BufRead * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
autocmd BufRead *
\ if expand('%:p') !~# '\m/\.git/' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" html
autocmd BufNewFile *.html 0r $HOME/.vim/templates/skel.html
augroup End
" -------------------
" function
" -------------------
"行頭のスペースの連続をハイライト
"Tab文字も区別されずにハイライトされるので、区別したいときはTab文字の表示を別に
"設定する必要がある。
function! SOLSpaceHilight()
syntax match SOLSpace "^\s\+" display containedin=ALL
highlight SOLSpace term=underline ctermbg=darkblue
endf
"全角スペースをハイライト
function! JISX0208SpaceHilight()
syntax match JISX0208Space " " display containedin=ALL
highlight JISX0208Space term=underline ctermbg=LightCyan
endf
"行末スペースをハイライト
function! TrailedSpaceHightlight()
syntax match TrailedSpace "[ \t]\+$" display containedin=ALL
highlight TrailedSpace term=underline ctermbg=Red guibg=Red
endf
"syntaxの有無をチェックし、新規バッファと新規読み込み時にハイライトさせる
if has('syntax')
syntax on
augroup invisible
autocmd! invisible
"autocmd BufNew,BufRead * call SOLSpaceHilight()
autocmd BufNew,BufRead * call JISX0208SpaceHilight()
autocmd BufNew,BufRead * call TrailedSpaceHightlight()
augroup END
endif
":function! HtmlEscape()
"silent s/&/\&/eg
"silent s/</\</eg
"silent s/>/\>/eg
":endfunction
"
":function! HtmlUnEscape()
"silent s/</</eg
"silent s/>/>/eg
"silent s/&/\&/eg
":endfunction
" -------------------
" plugin
" -------------------
"vim-ruby
"Rubyのオムニ補完を設定(ft-ruby-omni)
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
let ruby_space_errors = 1
"vim-rails
let g:rails_level=4
let g:rails_statusline=1
function! Rspec ()
let rails_spec_pat = '\<spec/\(models\|controllers\|views\|helpers\)/.*_spec\.rb$'
if expand('%:p') =~ rails_spec_pat
exe '!ruby script/spec -fn -c %:p -l '.line('.')
"exe '!rake spec SPEC="'.expand('%:p').'" RSPECOPTS="-fs -c -l '.line('.').'"'
else
:!rspec -fn -c %
endif
endfunction
autocmd BufRead,BufNewFile *_spec.rb :command! Rs :call Rspec()
"rspec on quickrun
let g:quickrun_config = {}
let g:quickrun_config['ruby.rspec'] = {'command':'rspec'}
augroup MyRSpec
autocmd!
autocmd BufWinEnter,BufNewFile *_spec.rb set filetype=ruby.rspec
augroup END
"fuzzy_finder
augroup FuzzyFinder
autocmd!
autocmd FileType fuf nmap <C-c> <ESC>
augroup END
let g:fuf_patternSeparator = ' '
let g:fuf_modesDisable = ['mrucmd']
let g:fuf_mrufile_exclude = '\v\.DS_Store|\.git|\.swp|\.svn'
let g:fuf_mrufile_maxItem = 100
let g:fuf_enumeratingLimit = 20
let g:fuf_file_exclude = '\v\.DS_Store|\.git|\.swp|\.svn'
"smartchr
"inoremap <expr> <buffer> { smartchr#loop('{', '#{', '{{{')
"inoremap <buffer> <expr> = smartchr#loop(' = ', ' == ', '=')
"inoremap <buffer> <expr> <S-=> smartchr#loop(' + ', '+')
"inoremap <buffer> <expr> - smartchr#loop(' - ', '-')
"inoremap <buffer> <expr> , smartchr#loop(', ', ',')
"inoremap <buffer> <expr> . smartchr#loop('.', '<%= %>', '<% %>')
"inoremap <buffer> <expr> . smartchr#loop('.', '<%= %><LEFT><LEFT><LEFT>', '<% %><LEFT><LEFT><LEFT>')
"rsense
"let g:rsenseHome = "/Users/snoozer/lib/rsense-0.3"
"let g:rsenseUseOmniFunc = 1
"neocomplcache
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_max_list = 30
let g:neocomplcache_enable_smart_case = 1
"" like AutoComplPop
let g:neocomplcache_enable_auto_select = 1
"" search with camel case like Eclipse
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:NeoComplCache_EnableSkipCompletion = 0
if !exists('g:NeoComplCache_OmniPatterns')
let g:NeoComplCache_OmniPatterns = {}
endif
let g:NeoComplCache_OmniPatterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
"inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-e> neocomplcache#cancel_popup()
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
"snippets
"let g:NeoComplCache_SnippetsDir = '~/.vim/snippets'
let g:neosnippet#snippets_directory = '~/.vim/snippets'
"imap <C-k> <Plug>(neocomplcache_snippets_expand)
"smap <C-k> <Plug>(neocomplcache_snippets_expand)
"inoremap <expr><C-g> neocomplcache#undo_completion()
"inoremap <expr><C-l> neocomplcache#complete_common_string()
"<TAB>でスニペット補完
if g:neocomplcache_enable_at_startup
imap <expr><TAB> neosnippet#expandable() ? "\<Plug>(neosnippet_jump_or_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
endif
"ambicmd
cnoremap pi<CR> :PluginInstall
cnoremap pu<CR> :PluginInstall!
"indent-guids
"let g:indent_guides_enable_on_vim_startup = 1
"let g:indent_guides_color_change_percent = 30
"let g:indent_guides_guide_size = 1
""set background=dark
"hi IndentGuidesOdd ctermbg=grey
"hi IndentGuidesEven ctermbg=darkgrey
" syntastic
" activeだとバッファを保存するたびにsyntasticが走る
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': ['ruby', 'javascript'] }
let g:syntastic_ruby_checkers = ['rubocop']
let g:syntastic_javascript_checker = 'jshint'
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'