-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
.vimrc
395 lines (362 loc) · 9.38 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
function! s:vimrc_environment()
let env = {}
let env.is_windows = has('win16') || has('win32') || has('win64')
let env.is_cygwin = has('win32unix')
let env.is_mac = !env.is_windows && !env.is_cygwin
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
\ (!executable('xdg-open') &&
\ system('uname') =~? '^darwin'))
let env.is_linux = !env.is_mac && has('unix')
let env.is_starting = has('vim_starting')
let env.is_gui = has('gui_running')
if env.is_windows
let vimpath = expand('~/vimfiles')
else
let vimpath = expand('~/.vim')
endif
" neovim
let env.path = {
\ 'vim': vimpath,
\ }
return env
endfunction
let g:env = s:vimrc_environment()
let g:pkg = {
\ "plug": expand(g:env.path.vim) . "/autoload/plug.vim",
\ "url": "https://raw.github.com/junegunn/vim-plug/master/plug.vim",
\ "github": "https://github.com/junegunn/vim-plug",
\ }
function! g:pkg.installed(name)
return has_key(self.plugins, a:name) ? isdirectory(self.plugins[a:name].dir) : 0
endfunction
function! g:pkg.check_installation()
if empty(self.plugins)
return
endif
let list = []
for [name, spec] in items(self.plugins)
if !isdirectory(spec.dir)
call add(list, spec.uri)
endif
endfor
if len(list) > 0
let unplugged = map(list, 'substitute(v:val, "^.*github\.com/\\(.*/.*\\)\.git$", "\\1", "g")')
echomsg 'Not installed plugins: ' . string(unplugged)
if confirm('Install plugins now?', "yes\nNo", 2) == 1
PlugInstall
endif
endif
endfunction
function! g:pkg.ready()
return filereadable(self.plug)
endfunction
if g:pkg.ready()
call plug#begin()
Plug 'AndrewRadev/gapply.vim'
Plug 'Dkendal/fzy-vim'
Plug 'aliou/bats.vim'
Plug 'babarot/vim-ansible-vault'
Plug 'babarot/vim-hcl'
Plug 'babarot/vim-shellutils'
Plug 'babarot/vim-sqlfmt'
Plug 'babarot/vim-unicode'
Plug 'chrisbra/csv.vim'
Plug 'christianrondeau/vim-base64'
Plug 'cocopon/vaffle.vim'
Plug 'hashivim/vim-terraform'
Plug 'haya14busa/vim-gofmt'
Plug 'hotwatermorning/auto-git-diff'
Plug 'juliosueiras/vim-terraform-completion'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'juvenn/mustache.vim'
Plug 'osyo-manga/vim-anzu'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-surround'
Plug 'tyru/caw.vim'
Plug 'w0rp/ale'
" syntax? language support
Plug 'cespare/vim-toml', { 'for': 'toml' }
Plug 'chase/vim-ansible-yaml'
Plug 'dag/vim-fish', { 'for': 'fish' }
Plug 'elzr/vim-json', { 'for': 'json' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'jelera/vim-javascript-syntax', { 'for': 'javascript' }
Plug 'jnwhiteh/vim-golang', { 'for': 'go' }
Plug 'keith/tmux.vim', { 'for': 'tmux' }
Plug 'maksimr/vim-jsbeautify', { 'for': 'javascript' }
Plug 'rhysd/vim-gfm-syntax', { 'for': 'markdown' }
Plug 'rhysd/vim-fixjson', { 'for': 'json' }
Plug 'tsandall/vim-rego'
" colorscheme
Plug 'AlessandroYorba/Despacio'
Plug 'arcticicestudio/nord-vim'
Plug 'altercation/vim-colors-solarized'
Plug 'chriskempson/vim-tomorrow-theme'
Plug 'cocopon/iceberg.vim'
Plug 'junegunn/seoul256.vim'
Plug 'morhetz/gruvbox'
Plug 'nanotech/jellybeans.vim'
Plug 'nightsense/snow'
Plug 'nightsense/stellarized'
Plug 'tomasr/molokai'
Plug 'w0ng/vim-hybrid'
Plug 'yuttie/hydrangea-vim'
Plug 'caglartoklu/ftcolor.vim'
call plug#end()
endif
" g:plugs is set by vim-plug
let g:pkg.plugins = get(g:, 'plugs', {})
if has('reltime')
let g:startuptime = reltime()
augroup vimrc-startuptime
autocmd!
autocmd VimEnter * let g:startuptime = reltime(g:startuptime) | redraw
\ | echomsg 'startuptime: ' . reltimestr(g:startuptime)
augroup END
endif
if !g:pkg.ready()
function! g:pkg.init()
let ret = system(printf("curl -fLo %s --create-dirs %s", self.plug, self.url))
if v:shell_error
return Error('g:pkg.init: error occured')
endif
" Restart vim
if !g:env.is_gui
silent! !vim
quit!
endif
endfunction
command! PlugInit call g:pkg.init()
autocmd! VimEnter * redraw
\ | echohl WarningMsg
\ | echo "You should do ':PlugInit' at first!"
\ | echohl None
endif
set number
set showtabline=2
set laststatus=3
set t_Co=256
set pumheight=10
set lazyredraw
set ttyfast
set modeline
set modelines=5
set keywordprg=:help
set helplang& helplang=ja
set ignorecase
set smartcase
set incsearch
set hlsearch
set autoread
set autowrite
set switchbuf=useopen,usetab,newtab
set nostartofline
set expandtab
set autoindent
set backspace=indent,eol,start
set wrapscan
set showmatch
set matchtime=1
set matchpairs& matchpairs+=<:>
set wildmenu
set wildmode=longest,full
set wildignore&
set wildignore=.git,.hg,.svn
set wildignore+=*.jpg,*.jpeg,*.bmp,*.gif,*.png
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.so,*.out,*.class
set wildignore+=*.swp,*.swo,*.swn
set wildignore+=*.DS_Store
set ruler
set rulerformat=%m%r%=%l/%L
set shiftwidth=4
set tabstop=4
let &showbreak = '+++ '
set laststatus=2
set cmdheight=2
set showmode
set showcmd
set notitle
set smartindent
set smarttab
set whichwrap=b,s,h,l,<,>,[,]
set hidden
set textwidth=0
set formatoptions&
set formatoptions-=t
set formatoptions-=c
set formatoptions-=r
set formatoptions-=o
set formatoptions-=v
set formatoptions+=l
set list
set listchars=tab:>-,trail:-,nbsp:%,extends:>,precedes:<,eol:<
set listchars=eol:<,tab:>.
set nrformats=alpha,hex
set winaltkeys=no
set novisualbell
set vb t_vb=
set noequalalways
set history=10000
set wrap
set mousehide
set virtualedit=block
set virtualedit& virtualedit+=block
set fileformat=unix
set fileformats=unix,dos,mac
if exists('&ambiwidth')
set ambiwidth=double
endif
set encoding=utf-8
set fileencoding=japan
set fileencodings=utf-8,iso-2022-jp,euc-jp,ucs-2le,ucs-2,cp932
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,iso-2022-jp,euc-jp,ucs-2le,ucs-2,cp932
set foldenable
set foldlevel=0
set foldcolumn=2
set iminsert=0 imsearch=0
set noimcmdline
if has('persistent_undo')
set undofile
let &undodir = g:env.path.vim . '/undo'
call mkdir(&undodir, "p")
endif
if has('clipboard')
set clipboard=unnamed
endif
" Define mapleader
let g:mapleader = ','
let g:maplocalleader = ','
nmap <Space> [Space]
xmap <Space> [Space]
nnoremap [Space] <Nop>
xnoremap [Space] <Nop>
noremap [Space]h ^
noremap [Space]l $
inoremap <C-h> <Backspace>
inoremap <C-d> <Delete>
cnoremap <C-k> <UP>
cnoremap <C-j> <DOWN>
cnoremap <C-l> <RIGHT>
cnoremap <C-h> <LEFT>
cnoremap <C-d> <DELETE>
cnoremap <C-p> <UP>
cnoremap <C-n> <DOWN>
cnoremap <C-f> <RIGHT>
cnoremap <C-b> <LEFT>
cnoremap <C-a> <HOME>
cnoremap <C-e> <END>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-d> <Del>
cnoremap <C-h> <BS>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-h> <BS>
inoremap <C-d> <Del>
inoremap <C-f> <Right>
inoremap <C-b> <Left>
inoremap <C-n> <Up>
inoremap <C-p> <Down>
inoremap <C-m> <CR>
nnoremap q: <Nop>
nnoremap q/ <Nop>
nnoremap q? <Nop>
nnoremap <Up> <Nop>
nnoremap <Down> <Nop>
nnoremap <Left> <Nop>
nnoremap <Right> <Nop>
nnoremap ZZ <Nop>
nnoremap ZQ <Nop>
inoremap jj <ESC>
cnoremap <expr> j getcmdline()[getcmdpos()-2] ==# 'j' ? "\<BS>\<C-c>" : 'j'
vnoremap <C-j><C-j> <ESC>
onoremap jj <ESC>
inoremap j[Space] j
onoremap j[Space] j
nnoremap : ;
nnoremap ; :
nnoremap q; q:
vnoremap : ;
vnoremap ; :
vnoremap q; q:
cnoreabbrev w!! w !sudo tee > /dev/null %
nnoremap <silent> <ESC><ESC> :nohlsearch<CR>
nnoremap n nzz
nnoremap N Nzz
nnoremap S *zz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
nnoremap <silent><CR> :<C-u>silent update<CR>
noremap gf gF
noremap gF gf
vnoremap v $h
nnoremap Y y$
noremap <expr> zz (winline() == (winheight(0)+1)/ 2) ? 'zt' : (winline() == 1) ? 'zb' : 'zz'
" Jump a next blank line
nnoremap <silent>W :<C-u>keepjumps normal! }<CR>
nnoremap <silent>B :<C-u>keepjumps normal! {<CR>
" Save word and exchange it under cursor
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>
" Yank the entire file
nnoremap <Leader>y :<C-u>%y<CR>
nnoremap <Leader>Y :<C-u>%y<CR>
nnoremap t <Nop>
nnoremap <silent> [Space]t :<C-u>tabclose<CR>:<C-u>tabnew<CR>
nnoremap <silent> tt :<C-u>tabnew<CR>
nnoremap <silent> tT :<C-u>tabnew<CR>:<C-u>tabprev<CR>
nnoremap <silent> tc :<C-u>tabclose<CR>
nnoremap <silent> to :<C-u>tabonly<CR>
nnoremap <silent> tm :<C-u>call <SID>move_to_tab()<CR>
function! s:move_to_tab()
tab split
tabprevious
if winnr('$') > 1
close
elseif bufnr('$') > 1
buffer #
endif
tabnext
endfunction
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap gj j
nnoremap gk k
vnoremap gj j
vnoremap gk k
nnoremap <silent> <C-x>d :Delete<CR>
nnoremap <silent> <C-x><C-d> :Delete!<CR>
nnoremap s <Nop>
nnoremap sp :<C-u>split<CR>
nnoremap vs :<C-u>vsplit<CR>
function! s:vsplit_or_wincmdw()
if winnr('$') == 1
return ":vsplit\<CR>"
else
return ":wincmd w\<CR>"
endif
endfunction
nnoremap <expr><silent> ss <SID>vsplit_or_wincmdw()
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sl <C-w>l
nnoremap sh <C-w>h
augroup vimrc-check-plugins
autocmd!
autocmd VimEnter * if !argc() | call g:pkg.check_installation() | endif
augroup END
let g:MRU_Auto_Close = 1
let g:MRU_Window_Height = 30
let g:MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*'
let g:MRU_Max_Entries = 1000
nnoremap <silent> [Space]j :<C-u>MRU<CR>
call map(sort(split(globpath(&runtimepath, '_config/*.vim'))), {->[execute('exec "source" v:val')]})