-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
555 lines (474 loc) · 15.8 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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
" .vimrc
" janus_wel <[email protected]>
" basic options {{{1
set nocompatible " compatible mode off
" NeoBundle {{{1
filetype off
filetype plugin indent off
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
set runtimepath+=~/vimfiles/bundle/neobundle.vim/
call neobundle#begin(expand('~/.vim/bundle/'))
endif
" plugins
if !exists('g:vscode')
NeoBundle 'januswel/jwlib.vim'
NeoBundle 'januswel/binedit.vim'
NeoBundle 'januswel/fencdefault.vim'
NeoBundle 'januswel/protect.vim'
NeoBundle 'januswel/setscroll.vim'
NeoBundle 'januswel/smrtcmpl.vim'
NeoBundle 'januswel/sweepbuf.vim'
NeoBundle 'januswel/tabshift.vim'
NeoBundle 'januswel/visualiz.vim'
NeoBundle 'januswel/zoomfont.vim'
NeoBundle 'januswel/autotmpl.vim'
NeoBundle 'januswel/count.vim'
NeoBundle 'januswel/expand.vim'
NeoBundle 'januswel/filer.vim'
NeoBundle 'januswel/profile.vim'
NeoBundle 'januswel/sendbrowser.vim'
NeoBundle 'januswel/uniconv.vim'
NeoBundle 'januswel/rlhelp.vim'
NeoBundle 'w0rp/ale'
NeoBundle 'junegunn/vader.vim'
NeoBundle 'tpope/vim-fugitive'
" filetype settings
NeoBundle 'januswel/html5.vim'
NeoBundle 'januswel/powershell.vim'
NeoBundle 'januswel/go.vim'
NeoBundle 'januswel/prettier.vim'
NeoBundle 'januswel/sql.vim'
NeoBundle 'cespare/vim-toml'
NeoBundle 'editorconfig/editorconfig-vim'
NeoBundle 'isRuslan/vim-es6'
NeoBundle 'posva/vim-vue'
NeoBundle 'januswel/plantuml-syntax', 'add-command-to-preview'
NeoBundle 'rust-lang/rust.vim'
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'linux' : 'make',
\ 'unix' : 'gmake',
\ },
\ }
NeoBundle 'Quramy/tsuquyomi'
NeoBundle 'leafgarland/typescript-vim'
NeoBundle 'lepture/vim-velocity'
call neobundle#end()
endif
" options {{{1
" general {{{2
" viminfo
set viminfo+=% " save and restore the buffer list
" path setting
set path^=~/bin/ " prepend my bin to 'path'
" disable bell
set belloff=all
" timing to write
set noautowrite " disable writing files automatically
set noautowriteall " make my wish to vim thoroughly
" wait till input is determined
set notimeout " don't make me hurry
set nottimeout " once agein, don't
" backup {{{2
" The directories that are named as "backup" and found in runtime-paths are
" set in 'backupdir'.
let s:candidates = split(globpath(&runtimepath, 'backup'), '\n')
let s:backupdirs = []
let s:candidate = ''
for s:candidate in s:candidates
if isdirectory(s:candidate)
call add(s:backupdirs, s:candidate)
endif
endfor
" Backup feature is enabled when there are one or more directories that suit
" above conditions exist.
let s:backupdir = join(s:backupdirs, ',')
if s:backupdir != ''
set backup " backup feature on
set writebackup " make a backup file before overwriting a file
set backupcopy=auto " how backup files are created, best one
set backupext=~ " trailing character of backup file
let &backupdir = s:backupdir . ',' . &backupdir
endif
unlet s:candidates s:backupdirs s:candidate s:backupdir
" undo {{{2
if has('persistent_undo')
" The directories that are named as "undo" and found in runtime-paths are
" set in 'undodir'.
let s:candidates = split(globpath(&runtimepath, 'undo'), '\n')
let s:undodirs = []
let s:candidate = ''
for s:candidate in s:candidates
if isdirectory(s:candidate)
call add(s:undodirs, s:candidate)
endif
endfor
let s:undodir = join(s:undodirs, ',')
if s:undodir != ''
let &undodir = s:undodir . ',' . &undodir
endif
unlet s:candidates s:undodirs s:candidate s:undodir
endif
" display & information {{{2
set showtabline=2 " show tab bar always
set number " show line numbers
set noruler " don't show row and column number of cursor
set title " display editing file name at title bar
set laststatus=2 " show status line always
set showmode " show mode name
set cmdheight=1 " height of command-line is 1 row
set showmatch " show pair parentheses, brackets and so on
set scrolloff=3 " above and below cursor number is 3 line
set showcmd " show entered and partial command
set nolist " don't show space characters (tab, line break)
set confirm " confirm me before quitting modified buffers
" statusline {{{2
" %3(%m%) : modified flag (bracketed, fixed)
" %< : where to truncate line
" %3n : buffer number (3 digit)
" %t : filename (only leaf)
" %y : filetype (bracketed)
" %{&fenc!=#""?&fenc:&enc} : fileencoding
" %{&ff} : fileformat
" %r : read only flag (bracketed)
" %= : spliter left between right
" %{tabpagenr()} : current tabnumber
" %{tabpagenr("$")} : tabpage count
" %v : virtual column
" %l : line number
" %L : lines count
" %{strtrans(matchstr(getline("."),".",col(".")-1))} : chars under the cursor
" 0x%04B : hexadecimal octets
" %3P : percentage through file of displayed window
let s:statusline = [
\ '%3(%m%) %<%3n %t %y',
\ '[%{&fenc!=#""?&fenc:&enc}:%{&ff}]',
\ '%r',
\ '%=',
\ '[%{tabpagenr()}/%{tabpagenr("$")}]',
\ '[%v:%l/%L]',
\ '[%2(%{strtrans(matchstr(getline("."),".",col(".")-1))}%)',
\ ' 0x%04B]',
\ '[%3P]',
\ ]
let &statusline = join(s:statusline, '')
unlet s:statusline
" show status line always
set laststatus=2
" tabline {{{2
let &tabline = '%!jwlib#tabline#NoMouseTabLine('
\ . '"jwlib#tabline#ExtAndFileTypeTabLabel"'
\ . ')'
" tab, space and indent {{{2
set tabstop=4 " tab width
set shiftwidth=4 " number of spaces inserted by cindent, <<, >> and so on
" number of spaces inserted by <Tab> or deleted by <BS> (enterd by user)
set softtabstop=0 " when this is set to 0, use content of 'tabstop'
set expandtab " expand tab to spaces
set autoindent " auto indent on
" search {{{2
set incsearch " incremental search on
set hlsearch " highlight matched word
set ignorecase " use ignore case normally
set smartcase " but use match case when capital character is contained
set wrapscan " search wrap around the end of the file
" diff {{{2
set diffopt=filler,context:5 " show filler lines
" and use a context of 5 lines
" window {{{2
set splitbelow " make a new window at the below of the current window
set splitright " make a new window at the right of the current window
set helpheight=0 " a height of help window is half of the current window
" editing {{{2
" allow backspacing over autoindent, line breaks, start of insert
set backspace=indent,eol,start
" <C-A> and <C-X> affect also hexadecimal number and single alphabet
set nrformats=hex,alpha
" use IM
if has('xim') || has('multi_byte_ime') || has('global-ime')
set noimdisable
endif
" ignore CJK characters when spell checking
set spelllang=cjk,en
" completion {{{2
" command-line mode
set wildmenu " command-line completion on
set wildmode=list:longest " list all candidates and complete longest matched
" insert mode
" scanning places (and order) by keyword completion
" . : current buffer
" w : buffers from other windows
" b : other loaded buffers
" t : tab completion
" i : current and included files
set complete=.,w,b,t,i
" options
" menu : use a popup menu
" menuone : use a popup menu also when only one match
" preview : show extra information in the preview window
set completeopt=menu,menuone,preview
" encoding & format {{{2
" 'fileencodings' is set by plugin "jaencs.vim"
if has('win32')
if has('gui_running')
let &termencoding = &encoding
set encoding=utf-8
else
set encoding=cp932
endif
endif
" language and encoding of menu
if has('menu') && has('multi_lang')
set langmenu=ja.utf-8
endif
" end-of-line format
" candidates of EOL format for exist files
" first one is used as new file's EOL format
set fileformats=unix,dos
" platform specific {{{2
" for East Asian Width Class Ambiguous
if !exists('g:vscode')
if exists('&ambiwidth')
set ambiwidth=double
endif
endif
" clipboard is used as unnamed register
if has('clipboard')
set clipboard=unnamed
endif
" :hardcopy
if has('printer')
set printoptions=number:y
set printheader=%<%t%=page\ %N
if has('win32')
set printfont=VL_Gothic:h12:cSHIFTJIS
endif
endif
" C/Migemo
" this settings influence only Kaoriya version
if has('migemo')
set migemo
set migemodict=$VIM/dict/utf-8.d/migemo-dict
if has('mac')
set migemodict=$VIMRUNTIME/dict/migemo-dict
endif
endif
" filetype {{{1
filetype on " filetype detection on
filetype plugin on " for omni completion
filetype indent on " each filetype indent on
" syntax highlight {{{1
syntax enable " use syntax highlight
" color scheme: Janus.vim
colorscheme Janus " my color scheme
" let {{{1
" general {{{2
" <Leader>, <LocalLeader>
let mapleader = ','
let maplocalleader = ';'
" plugin: autodate.vim
" date format to insert automatically
let autodate_format = '%Y %3m %d'
" for :TOhtml
let g:html_font = 'VL Gothic'
"let g:html_ignore_folding = 1
let g:html_no_pre = 1
let g:html_number_lines = 1
let g:html_use_css = 1
let g:html_use_encoding = &encoding
let g:use_xhtml = 1
" plugin {{{2
let g:ale_sign_column_always = 1
" ftplugin {{{2
let g:rustfmt_autosave = 1
let g:rustfmt_command = '$HOME/.cargo/bin/rustfmt'
" disable plugin {{{2
" settings for Kaoriya version
if has('kaoriya')
let plugin_cmdex_disable = 1
let plugin_dicwin_disable = 1
let plugin_format_disable = 1
let plugin_hz_ja_disable = 1
let plugin_scrnmode_disable = 1
let plugin_verifyenc_disable = 1
" don't source gvimrc_example.vim in $VIM
" see $VIM/gvimrc
let no_gvimrc_example = 1
endif
" platform specific {{{2
if has('win32')
" in Windows, processing tar, gzip and zip with vim is non-sense...
let loaded_gzip = 1
let loaded_tarPlugin = 1
let loaded_zipPlugin = 1
else
" setting for bash (:help sh.vim)
let is_bash = 1
endif
" mappings {{{1
" general {{{2
" make
nnoremap <silent><Leader>m :update<CR>:make! "%"<CR>
" show buffer list
nnoremap <silent><Leader>b :buffers<CR>
" yank all lines of the buffer
nnoremap <silent><Leader>y :%yank<CR>
" toggle spell check
if has('spell') && has('syntax')
nnoremap <silent><Leader>s :setlocal spell!<CR>:setlocal spell?<CR>
endif
" cursor {{{2
" move cursor as it looks
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap ^ g^
nnoremap $ g$
vnoremap j gj
vnoremap k gk
vnoremap 0 g0
vnoremap ^ g^
vnoremap $ g$
" disable "," and ";" to use as mapleader and maplocalleader
nmap , <Nop>
nmap ; <Nop>
vmap , <Nop>
vmap ; <Nop>
" window & tabpage {{{2
" move cursor among windows, to next one and to previous one
nnoremap <silent><C-j> :wincmd w<CR>
nnoremap <silent><C-k> :wincmd W<CR>
" :tabnew is hard to complete
nnoremap t :tabnew<Space>
" open the buffer in a new tab page from the buffer list
nnoremap <S-t> :tab sbuffer<Space>
" shows list if there are more than one candidates, when jump over tags
nnoremap <silent><C-]> g]
" switch between tabpages
nnoremap <C-h> gT
nnoremap <C-l> gt
" move a tabpage around
" plugin: TabShift.vim
nnoremap <silent><C-p> :TabShift! -1<CR>
nnoremap <silent><C-n> :TabShift! +1<CR>
" searches {{{2
" put matched word in the top of the screen
" "zv" indicates to open fold
" "zt" indicates to redraw screen with the cursor line as the top of the screen
nnoremap n nzvzt
nnoremap N Nzvzt
nnoremap * *zvzt
nnoremap # #zvzt
nnoremap g* g*zvzt
nnoremap g# g#zvzt
" stop the highlighting matched texts
nnoremap <silent><Leader>h :nohlsearch<CR>
" clear search pattern
nnoremap <silent><Leader><S-h> :let @/=''<CR>
" matches {{{2
" clear match pattern
nnoremap <silent><Leader><S-t> :match<CR>
" show CHARACTER TABULATION
nnoremap <silent><Leader>t :match Error /\t/<CR>
" editing {{{2
" line break, mnemonic: "S"plit
nnoremap <S-s> i<CR><Esc>
" to upper case
inoremap <C-u> <Esc>gUiw`]a
" to camel case
inoremap <C-c> <Esc>bgUllgue`]a
" camelCase to kebabu-case
vnoremap <Leader>cck :s/\<\@!\([A-Z]\)/-\l\1/g<CR>:nohlsearch<CR>
" kebabu-case to camelCase
vnoremap <Leader>ckc :s/-\([a-z]\)/\u\1/g<CR>:nohlsearch<CR>
" camelCase to SNAKE_CASE
vnoremap <Leader>ccs :s/\<\@!\([A-Z]\)/_\1/g<CR>:nohlsearch<CR>gUiw
" SNAKE_CASE to camelCase
vnoremap <Leader>csc gugv:s/_\([a-z]\)/\U\1/g<CR>:nohlsearch<CR>
" tuck it
" U+0020 SPACE
vnoremap <Leader><Space> <Esc>`>a <Esc>`<i <Esc>
" U+0027 APOSTROPHE and U+0022 QUOTATION MARK
vnoremap <Leader>' <Esc>`>a'<Esc>`<i'<Esc>
vnoremap <Leader>" <Esc>`>a"<Esc>`<i"<Esc>
" U+0060 GRAVE ACCENT
vnoremap <Leader>` <Esc>`>a`<Esc>`<i`<Esc>
" U+002A ASTERISK
vnoremap <Leader>* <Esc>`>a*<Esc>`<i*<Esc>
" parentheses, curly, square and angle brackets
vnoremap <Leader>( <Esc>`>a)<Esc>`<i(<Esc>
vnoremap <Leader>{ <Esc>`>a}<Esc>`<i{<Esc>
vnoremap <Leader>[ <Esc>`>a]<Esc>`<i[<Esc>
vnoremap <Leader>< <Esc>`>a><Esc>`<i<<Esc>
" U+0025 PERCENT SIGN
vnoremap <Leader>% <Esc>`>a%<Esc>`<i%<Esc>
" U+005F LOW LINE
vnoremap <Leader>_ <Esc>`>a_<Esc>`<i_<Esc>
" U+007C VERTICAL LINE
" see :help map_bar
vnoremap <Leader>| <Esc>`>a|<Esc>`<i|<Esc>
" U+003A COLON
vnoremap <Leader>: <Esc>`>a:<Esc>`<i:<Esc>
" entity references, less and greater than sign
vnoremap <Leader>a <Esc>`>a><Esc>`<i<<Esc>`[
" xhtml inline tags
vnoremap <Leader>k <Esc>`>a<lt>/kbd><Esc>`<i<lt>kbd><Esc>`[
vnoremap <Leader>c <Esc>`>a<lt>/code><Esc>`<i<lt>code><Esc>`[
vnoremap <Leader>d <Esc>`>a<lt>/del><Esc>`<i<lt>del><Esc>`[
vnoremap <Leader>i <Esc>`>a<lt>/ins><Esc>`<i<lt>ins><Esc>`[
vnoremap <Leader>q <Esc>`>a<lt>/q><Esc>`<i<lt>q><Esc>`[
" U+FF5E FULLWIDTH TILDE
vnoremap <Leader>w <Esc>`>a <C-q>uff5e<Esc>`<i<C-q>uff5e <Esc>`[
" U+300C LEFT CORNER BRACKET and U+300D RIGHT CORNER BRACKET
vnoremap <Leader>b <Esc>`>a<C-q>u300d<Esc>`<i<C-q>u300c<Esc>`[
" C style comment
vnoremap <Leader><S-c> <Esc>`>a*/<Esc>`<i/*<Esc>
" completion {{{2
inoremap <expr><Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr><S-Tab> pumvisible() ? "\<C-p>" : "\<Tab>"
" path operation {{{2
" show current directory
nnoremap <silent><Leader>d :pwd<CR>
" change directory to one that has the editing file
nnoremap <silent><Leader><S-d> :lcd %:p:h<CR>:pwd<CR>
" change directory to the upper one
nnoremap <silent><Leader>u :lcd ../<CR>:pwd<CR>
" plugin {{{2
" sweepbuflist.vim
nmap <silent><Leader><S-b> :SweepBuffers<CR>:buffers<CR>
" expandvar.vim
nmap <silent><Leader>e <Plug>ExpandExpression
nmap <silent><Leader><S-e> <Plug>EvalExpression
nmap <silent><Leader>c <Plug>GenerateCtags
" zoomfont.vim
nmap <silent>+ <Plug>ZoomIn
nmap <silent>- <Plug>ZoomOut
nmap <silent>& <Plug>ZoomReset
" abbreviation {{{1
" fix typo
abbreviate retrun return
abbreviate cosnt const
abbreviate scirpt script
abbreviate cludge kludge
abbreviate hlep help
abbreviate parcent percent
abbreviate persent percent
abbreviate parsent percent
abbreviate tilda tilde
abbreviate appropreate appropriate
abbreviate acknowledgement acknowledgment
" script {{{1
augroup tags
autocmd!
autocmd BufNewFile,BufRead *.h,*.hpp,*.c,*.cpp set tags+=~/tags
augroup END
augroup TypeScript
autocmd FileType typescript nmap <buffer> <Leader>t :
\ <C-u>echo tsuquyomi#hint()<CR>
augroup END
" }}}1
" vim: ts=4 sw=4 sts=0 et fdm=marker fdc=3