-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
459 lines (362 loc) · 12.2 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
" This is my personal .vimrc, feel free to use it with your own risk.
" Set not compatible with vi. This is useful for
" consecutive undo and others
set nocompatible
call plug#begin('~/.vim/plugged')
" NerdTree. Disabled as it is really slow, use newtr (vim's native
" file explorer) instead.
" See http://vimcasts.org/episodes/the-file-explorer/
"
" On-demand loading
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'Xuyuanp/nerdtree-git-plugin'
" Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
" Auto comment
Plug 'scrooloose/nerdcommenter'
" syntax things
Plug 'scrooloose/syntastic'
"Plug 'NLKNguyen/papercolor-theme'
Plug 'trevordmiller/nova-vim'
" syntax support
Plug 'pangloss/vim-javascript'
Plug 'elzr/vim-json'
Plug 'othree/jsdoc-syntax.vim' "JSODOC syntax highlight
Plug 'heavenshell/vim-jsdoc' "JSDOC generation
Plug 'mxw/vim-jsx' " JSX Support
Plug 'skammer/vim-css-color'
Plug 'hail2u/vim-css3-syntax'
" HTML
Plug 'mattn/emmet-vim'
" Tern (Intellissence)
"Plug 'marijnh/tern_for_vim', { 'do': 'npm install' }
" Auto complete
Plug 'Shougo/neocomplete.vim'
" Git
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" On files and buffers
Plug 'Shougo/unite.vim'
" Auto close
" Autoclose, brackets and quotes
Plug 'tpope/vim-surround'
Plug 'cohama/lexima.vim'
" Status bar
Plug 'vim-airline/vim-airline'
" Snippets
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
call plug#end()
" Use pathogen (Deprecated, use Plug instead)
" call pathogen#infect()
" Git, add spell checking and automatic wrapping at the
" recommended 72 columns to you commit messages
autocmd Filetype gitcommit setlocal spell textwidth=72
" set leaders
let mapleader = ","
let maplocalleader = "."
" load filetype plugins/indent settings
filetype plugin indent on
" Syntax highlight
syntax on
" Colorscheme
"set t_Co=256
"set background=dark
"colorscheme PaperColor
colorscheme nova
" NerdTree
" let NERDTreeShowHidden=1
" Set buffer to be hidden
set hidden
" Show line numbers
set number numberwidth=4
" Set cursorline
set cursorline
" Remove annoying beeps
set visualbell
set noerrorbells
" Don't create backup file
set nobackup
set noswapfile
" Relative line number
set number
set relativenumber
" set norelativenumber " to disable relative number
" Show all whitespaces http://stackoverflow.com/questions/1675688/make-vim-show-all-white-spaces-as-a-character/29787362#29787362
" There's differences how linux (ubuntu) and OSX renders the space
" used to represent space, ubuntu renders it larger than it should.
" Hence, a condition should be used to determin which unicode to use
let os = substitute(system('uname'), "\n", "", "")
if os == "Darwin"
set listchars=eol:¬,tab:▸\ ,trail:~,extends:>,precedes:<,space:␣
else
set listchars=eol:¬,tab:▸\ ,trail:~,extends:>,precedes:<,space:˽
endif
" Activate show whitespaces
"set list
" Hide whitespaces
"set nolist
" Syntastic
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = './node_modules/.bin/eslint'
highlight link SyntasticErrorSign SignColumn
highlight link SyntasticWarningSign SignColumn
highlight link SyntasticStyleErrorSign SignColumn
highlight link SyntasticStyleWarningSign SignColumn
" vim-jsx, javascript, react
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
" Indentation, set default to 4 spaces
set tabstop=4 " set tab to four spaces
set softtabstop=4
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " set autoindent on
set copyindent " copy prev indentation on autoindenting
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
" Search
set showmatch " set show matching parenthesis
set ignorecase " ignore case when search
set smartcase " ignore case if search pattern is all lower case, case sensitive if otherwise
set hlsearch " highlight search terms
set incsearch " show search matches as you type
" Wrapping
set nowrap
set laststatus=2
" Vim Javascript
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" latex-box plugin
" let g:LatexBox_latexmk_options="-pdf"
let g:LatexBox_output_type="pdf"
" vim-autopairs plugin
" make default exclude ` (backtick)
" let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', "`":"`"}
" vim latex plugin
" associate any tex file to tex instead of plaintex
let g:tex_flavor = "latex"
" vim airline
" powerline status bar for vim
let g:airline_powerline_fonts = 1
"""""""""
" Neocomplete
""""""""""
"Note: This option must be set in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
end
""""""""
" Neosnippet
""""""""
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"""""""""""
" Key mappings
"""""""""""
" Save file to ctrl+s
nnoremap <C-s> :w<cr>
inoremap <C-s> <esc>:w<cr>
" Removes all dangling whitespaces
nnoremap <leader>c :%s/\s\+$//<cr>
" Quit vim, 'ctrl+q' to quit without save
nnoremap <C-q> :q!<cr>
inoremap <C-q> <esc>:q!<cr>
" Save then quit -- Disabled, to enable open in window split
" nnoremap <C-w> :wq!<cr>
" inoremap <C-w> <esc>:wq!<cr>
" Fast edit .vimrc file
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
" Go to end of line with insert mode
" Useful when adding a ; at the end of
" a statement
nnoremap <C-a> $a
inoremap <C-a> <esc>$a
" Add an empty line above the current line.
" Useful when creating function with curly
" braces
nnoremap <C-o> ko
inoremap <C-o> <esc>ko
" Open newtr at current directory
noremap <C-\> :e.<CR>
" Move line up and down, ref http://stackoverflow.com/questions/7501092/can-i-map-alt-key-in-vim
" alt+k to move one line up
nnoremap ˚ :m .-2<cr>==
inoremap ˚ <esc>:m .-2<cr>==gi
" alt+j to move one line down
nnoremap ∆ :m .+1<cr>==
inoremap ∆ <esc>:m .+1<cr>==gi
" Surround a word with double quote
nnoremap <leader>" viW<esc>a"<esc>hBi"<esc>lel
" Surround a word with single quote
nnoremap <leader>' viW<esc>a'<esc>hBi'<esc>lel
" Surround a word with backtick
nnoremap <leader>` viW<esc>a`<esc>hBi`<esc>lel
" Surround a word with parentheses (a)
nnoremap <leader>() viW<esc>a)<esc>hBi(<esc>lel
" Surround a word with square bracket [a]
nnoremap <leader>[] viW<esc>a]<esc>hBi[<esc>lel
" Surround a word with curly bracket with spaces { a }
nnoremap <leader>{} viW<esc>a }<esc>hBi{ <esc>lel
" Use H to go to the beginning of a line, L to the end of a line
nnoremap H ^
nnoremap L $
" Disable escape keys, use jk instead
inoremap <esc> <nop>
inoremap jk <esc>
" Disable arrow keys
nnoremap <up> <nop>
nnoremap <left> <nop>
nnoremap <down> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <left> <nop>
inoremap <down> <nop>
inoremap <right> <nop>
inoremap OA <nop>
inoremap OC <nop>
inoremap OB <nop>
inoremap OD <nop>
" Use ctrl+j to insert new line in normal mode without entering insert mode
nnoremap <C-j> ciW<CR><Esc>:if match( @", "^\\s*$") < 0<Bar>exec "norm P-$diw+"<Bar>endif<CR>
" Use ctrl+l to clear the search highlight
nnoremap <silent> <C-l> :nohls<cr>
" Pastetoggle, useful if paste code from outside application.
" Use only in vim terminal, if in GUI set toggle off.
" Map toggle to ctrl+t
nnoremap <C-t> :set invpaste paste?<cr>
inoremap <C-t> <esc>:set invpaste paste?<cr>
" Insert a new line under current text without enter to insert mode
nnoremap <leader>o o<esc>
set pastetoggle=<C-t>
set showmode
" Move to another window split
nnoremap <leader>h :wincmd h<cr>
nnoremap <leader>j :wincmd j<cr>
nnoremap <leader>k :wincmd k<cr>
nnoremap <leader>l :wincmd l<cr>
" Wrap shortcut
nnoremap <leader>w :set wrap linebreak nolist<cr>
" Unite key mapping
nnoremap <C-f><C-s> <esc>:Unite file buffer<cr>
inoremap <C-f><C-s> <esc>:Unite file buffer<cr>
" PDV php documentor
let g:pdv_template_dir = $HOME ."/.vim/bundle/pdv/templates_snip"
nnoremap <buffer> <C-p> :call pdv#DocumentWithSnip()<CR>
" Set spell to en
nnoremap <leader>s :set spell spelllang=en<cr>
" Abbreviations
" typos
iabbrev adn and
iabbrev tehn then
iabbrev @@ nauval.atmaja@gmail.com
iabbrev @@1 noval.78@gmail.com
iabbrev @@a @author Nauval Atmaja <noval.78@gmail.com>
iabbrev @@b @author Nauval Atmaja <nauval.atmaja@gmail.com>
"" Autocommands -------------------------------------{{{
" Dissable generating comment in the next line after a comment line
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup filetype_js
autocmd!
" Indentation, set tab to be 2 spaces, ts: tabstop, sw: shiftwidth, sts: softtabstop
autocmd FileType javascript setlocal ts=2 sw=2 sts=2 expandtab
augroup END
augroup filetype_json
autocmd!
" Indentation, set tab to be 2 spaces, ts: tabstop, sw: shiftwidth, sts: softtabstop
autocmd FileType json setlocal ts=2 sw=2 sts=2 expandtab
augroup END
augroup filetype_html
autocmd!
" Indentation, set tab to be 4 spaces, ts: tabstop, sw: shiftwidth, sts: softtabstop
autocmd FileType xhtml setlocal ts=4 sw=4 sts=4 expandtab
augroup END
augroup filetype_php
autocmd!
autocmd FileType php setlocal expandtab
augroup END
"
"augroup filetype_python
"autocmd!
"autocmd FileType python nnoremap <buffer> <localleader>c I#<esc>
"augroup END
"
"
"augroup filetype_java
"autocmd!
"autocmd FileType java nnoremap <buffer> <localleader>c I//<esc>
"augroup END
" Vimscript file setting ----------------------------{{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
"" }}}