-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
380 lines (319 loc) · 9.56 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
" ======================
" vim configuration file
" @author suzuken (https://github.com/suzuken)
"
" README file is here:
"
" suzuken/dotfiles - GitHub
" https://github.com/suzuken/dotfiles
"
" Sorry for writing some comments in Japanese, and I'll translate to English
" later.
" ======================
" use https://github.com/junegunn/vim-plug
call plug#begin()
"Plugin Installing
Plug 'mattn/webapi-vim'
Plug 'The-NERD-Commenter'
Plug 'mattn/gist-vim'
Plug 'mattn/emmet-vim'
Plug 'altercation/vim-colors-solarized'
Plug 'Modeliner'
Plug 'tpope/vim-fugitive'
Plug 'thinca/vim-quickrun'
Plug 'ShowMarks'
Plug 'mattn/benchvimrc-vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'mileszs/ack.vim'
Plug 'Shougo/vimproc.vim'
Plug 'mattn/ctrlp-ghq'
Plug 'majutsushi/tagbar'
Plug 'mattn/sonictemplate-vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'justinmk/vim-dirvish'
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'garbas/vim-snipmate'
" Plugins for each languages
Plug 'puppetlabs/puppet-syntax-vim'
Plug 'wting/rust.vim', {'autoload':{'filetypes':['rust']}}
Plug 'derekwyatt/vim-scala', {'autoload':{'filetypes':['scala']}}
Plug 'vim-ruby/vim-ruby', {'autoload':{'filetypes':['ruby']}}
Plug 'fatih/vim-go', {'autoload':{'filetypes':['go']}}
Plug 'vim-php/tagbar-phpctags.vim', {'autoload':{'filetypes':['php']}}
Plug 'shawncplus/phpcomplete.vim', {'autoload':{'filetypes':['php']}}
Plug 'sumpygump/php-documentor-vim', {'autoload':{'filetypes':['php']}}
Plug '2072/PHP-Indenting-for-VIm', {'autoload':{'filetypes':['php']}}
Plug 'hynek/vim-python-pep8-indent', {'autoload':{'filetypes':['python']}}
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'othree/yajs.vim', {'autoload':{'filetypes':['javascript']}}
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'keith/swift.vim', {'autoload':{'filetypes':['swift']}}
Plug 'posva/vim-vue', {'autoload':{'filetypes':['vue']}}
Plug 'ekalinin/Dockerfile.vim'
call plug#end()
filetype plugin indent on
" =================
" showmarks_include
" =================
let g:showmarks_include="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"==========================
"init
"==========================
autocmd!
set modelines=5
let mapleader = ","
set tabstop=4
set expandtab
set softtabstop=0
set shiftwidth=4
set smarttab
set number
set title
set scrolloff=5
set ambiwidth=double
if has('gui_running')
set t_Co=16
let g:solarized_termcolors=16
else
" http://stackoverflow.com/questions/7278267/incorrect-colors-with-vim-in-iterm2-using-solarized
let g:solarized_termtrans = 1
endif
set background=dark
colorscheme solarized
if v:version >= 700
set cursorline
endif
set cmdheight=2
" highlight each language in markdown
" http://mattn.kaoriya.net/software/vim/20140523124903.htm
let g:markdown_fenced_languages = [
\ 'css',
\ 'go',
\ 'javascript',
\ 'js=javascript',
\ 'json=javascript',
\ 'ruby',
\ 'sass',
\ 'xml',
\ 'erlang',
\]
"==========================
"Searching and Moving
"==========================
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set gdefault " always %s/hoge/foo/ means %s/hoge/foo/g
set incsearch
set showmatch
set hlsearch
set wrapscan
" In visual mode, tab means insert <tab> into highlighted block.
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" always escape / and ? in search character.
cnoremap <expr> /
\ getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ?
\ getcmdtype() == '?' ? '\?' : '?'
"==========================
"Handling long lines
"==========================
set wrap
set formatoptions=qrn1
if v:version >= 730
set colorcolumn=85 "色づけ
endif
"==========================
"Key Bind
"==========================
" reload vimrc
noremap <C-c><C-c> <C-c>
noremap <C-c><C-e>e :edit $HOME/.vimrc<CR>
noremap <C-c><C-e>s :source $HOME/.vimrc<CR>
" when move to search results, move to center.
noremap n nzz
noremap N Nzz
noremap * *zz
noremap # #zz
noremap g* g*zz
noremap g# g#zz
nnoremap ; :
au FocusLost * :wa
"F2でpasteモードに。pasteするときにインデントを無効化。
" <F2> to paste mode.
set pastetoggle=<F2>
"splitの移動を簡単に。ctrl押しながらhjkl
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" <Enter> always means inserting line.
nnoremap <S-Enter> O<ESC>
nnoremap <Enter> o<ESC>
" Creating underline/overline headings for markup languages
" Inspired by http://sphinx.pocoo.org/rest.html#sections
nnoremap <leader>1 yyPVr=jyypVr=
nnoremap <leader>2 yyPVr*jyypVr*
nnoremap <leader>3 yyPVr-jyypVr-
nnoremap <leader>4 yypVr=
nnoremap <leader>5 yypVr-
nnoremap <leader>6 yypVr^
nnoremap <leader>7 yypVr"
"==========================
"language
"==========================
set encoding=utf-8
source $HOME/.vim/encode.vim
set fileformats=unix,dos,mac
set ambiwidth=double
"==========================
"clipboard
"==========================
set clipboard+=autoselect
"==========================
"special Key
"==========================
set list
set listchars=tab:>-,trail:-,extends:<,precedes:<
highlight specialKey ctermfg=darkgray
"==========================
"Input
"==========================
set backspace=indent,eol,start
set formatoptions+=mM
set autoindent
set smartindent
"==========================
"Command
"==========================
set wildmenu
set wildmode=full:list
"==========================
"Programming
"==========================
set showmatch "対応する括弧を表示
set foldmethod=syntax
set grepprg=internal "内蔵grep
"==========================
"Backup
"==========================
set autowrite
set hidden
set backup
set backupdir=$HOME/.vimback
set directory=$HOME/.vimtmp
set history=10000
set updatetime=500
"set viminfo=""
let g:svbfre = '.\+'
"==========================
"Status Line
"==========================
set showcmd "ステータスラインにコマンドを表示
set laststatus=2 "ステータスラインを常に表示
"==========================
"Window
"==========================
set splitright "Window Split時に新Windowを右に表示
set splitbelow "Window Split時に新windowを下に表示
"==========================
"File Type
"==========================
syntax on "シンタックスハイライト
if has('autocmd')
autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl
autocmd FileType python setl autoindent
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl tabstop=4 expandtab shiftwidth=4 softtabstop=4
autocmd FileType html :compiler tidy
autocmd FileType html :setlocal makeprg=tidy\ -raw\ -quiet\ -errors\ --gnu-emacs\ yes\ \"%\"
autocmd FileType html setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
autocmd BufNewFile,BufRead *.scala set filetype=scala
autocmd FileType scala setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
autocmd BufNewFile,BufRead *.q set filetype=sql
autocmd BufNewFile,BufRead *.twig set filetype=html
endif
"==========================
"help
"==========================
set helplang=en
let g:quickrun_config = {}
augroup my_dirvish_events
au!
au User DirvishEnter let b:dirvish.showhidden = 1
augroup END
"==========================
"NERDcommenter.vim
"==========================
let NERDSpaceDelims = 1
let NERDShutUp = 1
" =====================================================
"" ctags
" =====================================================
set tags=tags
" =====================================================
"" snipMate.vim
" =====================================================
let g:snips_author = 'Kenta Suzuki'
" =====================================================
"" sonictemplate
" =====================================================
let g:sonictemplate_vim_template_dir = [
\ '$HOME/.vim/templates',
\]
" =====================================================
"" tagbar
" =====================================================
noremap <leader>t :<c-u>TagbarToggle<cr>
" =====================================================
"" ack.vim
" =====================================================
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" =====================================================
"" ctrlp.vim
" =====================================================
let g:ctrlp_regexp = 0
let g:ctrlp_extensions = ['tag', 'buffertag', 'dir', 'mixed', 'bookmarkdir']
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll|class)$',
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
\ }
" ctrlp-ghq
" https://github.com/mattn/ctrlp-ghq
noremap <leader>g :<c-u>CtrlPGhq<cr>
" jad
" installation required http://varaneckas.com/jad/
augr class
au!
au bufreadpost,filereadpost *.class %!jad -noctor -ff -i -p %
au bufreadpost,filereadpost *.class set readonly
au bufreadpost,filereadpost *.class set ft=java
au bufreadpost,filereadpost *.class normal gg=G
au bufreadpost,filereadpost *.class set nomodified
augr END
"----------------------------------------------------
"" host specific
"----------------------------------------------------
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
function! HandleURI()
let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^>,;:]*')
" let s:uri = matchstr(getline("."), '/https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/')
echo s:uri
if s:uri != ""
exec "!open \"" . s:uri . "\""
else
echo "No URI found in line."
endif
endfunction
map <Leader>w :call HandleURI()<CR>
" http://stackoverflow.com/questions/916875/yank-file-name-path-of-current-buffer-in-vim
" set full path of current buffer to unamed register
nmap cp :let @" = expand("%")