-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
604 lines (558 loc) · 17.6 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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
"╭───────────────────────────╮
"│ ╻ ╻╻┏┳┓┏━┓┏━╸ ┏━╸╻╻ ┏━╸│
"│ ┃┏┛┃┃┃┃┣┳┛┃ ┣╸ ┃┃ ┣╸ │
"│ ┗┛ ╹╹ ╹╹┗╸┗━╸ ╹ ╹┗━╸┗━╸│
"╰───────────────────────────╯
"
" Plugins ---------------------------------------------------------------- {{{
call plug#begin('~/.vim/bundle')
Plug 'ervandew/supertab'
Plug 'mhinz/vim-startify'
Plug 'mhinz/vim-signify'
Plug 'osyo-manga/vim-over'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-markdown', {'for' : 'markdown'}
Plug 'ctrlpvim/ctrlp.vim', {'on' : ['CtrlPBuffer', 'CtrlPMRUFiles']}
Plug 'notpratheek/vim-luna'
Plug 'notpratheek/vim-sol'
Plug 'rstacruz/sparkup', {'for' : 'html'}
Plug 'jiangmiao/auto-pairs'
Plug 'maralla/completor.vim'
Plug 'google/vim-searchindex'
Plug 'w0rp/ale'
Plug 'mbbill/undotree', {'on': 'UndotreeToggle'}
Plug 'chrisbra/unicode.vim'
call plug#end()
" }}}
" Preamble ---------------------------------------------------------------- {{{
"
" No explanation needed
set nocompatible
set shell=/bin/bash
" }}}
" General Settings -------------------------------------------------------- {{{
"
" Better than just /<search term>
" Also, `\v` enables use of Perl compatible regexes
nmap / /\v
syntax on
" enable loading the indent file for specific file types
filetype indent on
" enable loading the plugin files for specific file types
filetype plugin on
" switch on syntax highlighting
syntax enable
" set a light background
" Useful with CtrlP
set hidden
set dictionary=/usr/share/dict/words
" standard width
set textwidth=80
" Have a different colorscheme for GUI and console version of Vim
if has('gui_running')
set background=light
colorscheme sol
else
set background=dark
colorscheme sol-term
endif
" Use ag over grep
" set grepprg=ag\ --nogroup\ --nocolor
set grepprg=rg\ --color=never
" I'm going to try to put a comment above most of these `set` stuff,
" but if its not present, just do a `:h` for that
" Always have a status bar
set laststatus=2
" UTF-8 encoding
set encoding=utf-8
" Number of colors
set t_Co=256
" line number
set number
set autoindent
set smartindent
set incsearch
" set listchars=tab:∙∙,eol:¬,trail:·
set listchars=tab:∙∙,trail:·,
set list
" Can *NEVER* settle with one font ! :D
" set guifont=Menlo\ for\ Powerline\ 13
" set guifont=Monaco\ for\ Powerline\ 13
" set guifont=Inconsolata\ Medium\ 17
" set guifont=Source\ Code\ Pro\ 15
" set guifont=DejaVu\ Sans\ Mono\ 15
set guifont=Fira\ Mono\ 15
set hlsearch
set wildmenu
" only show the ColorColumn when the cursor is on the 79th char of that line
call matchadd('ColorColumn', '\%80v', 100)
set cursorline
set tabstop=4
set expandtab
set softtabstop=4
set shiftwidth=4
set foldlevel=99
set foldmethod=indent
set breakindent
" swap files in a dir
set updatecount=10
set directory=~/.vim/swaps//
" set undofile and an undo dir
set undodir=~/.vim/undos//
set undofile
" Remember more previously used stuff
set history=1000
" Better term setting (read :h ttyfast for better understanding)
set ttyfast
" Stops screen from redrawing when macros are being executed
set lazyredraw
" NO WRAP ! EVER !
" This is especially usefull for `:vertical h <topic>`
set nowrap
" case insensitive commands
" Eg -- :start<Tab> ==> :Startify
set ignorecase smartcase
" Amount of time taken to show the matching paren
" (This is in tenths of a sec)
set matchtime=3
" Better completion
" do a `:h 'complete'`
set complete=.,w,b,u,t,i
" do a `:h 'completeopt'`
"set completeopt=longest,menuone,preview,menu
set completeopt=longest,menuone,menu
" I think all these guioptions should be in gvimrc,
" but since vimrc loads faster, I've added them here
" Empty string = No GUI features !
set guioptions=
" too many times :W ! Hence, the shortcut
ca W w
ca Qa qa
ca Wqa wqa
ca qa1 qa!
ca qA1 qa!
ca qA! qa!
" re-center the search results to the center of the screen
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
" remap : -> ;
nnoremap ; :
" }}}
" Status line -------------------------------------------------------------- {{{
" Begin Status line
"set statusline=\
" Show the mode
"set statusline+=%{toupper(mode())}\
" Buffer number
"set statusline+=[%n]\
" file name (full path of the file)
"set statusline+=%F\
" is file modified ?
"set statusline+=%m\
" shift stuff to right
"set statusline+=%=\
" is file READONLY?
"set statusline+=%r\
" Fugitive status
"set statusline+=%{fugitive#statusline()}\
" more to right
"set statusline+=%=\
" encoding
"set statusline+=%{(&fenc==\"\"?&enc:&fenc)}\
" fancy file format (first letteruppercase, rest of the letters lowercase)
" Eg -- html shown as Html
"set statusline+=%{toupper(strpart(&filetype,0,1)).strpart(&filetype,1)}\
" (current line:current column / total lines in file)
"set statusline+=%10(%l:%c/%L%)\
" percent position in the file
"set statusline+=%4(%p%%%)\
"set statusline+=%#error#
"set statusline+=%{StatuslineTabWarning()}
"set statusline+=%{StatuslineTrailingSpaceWarning()}
"set statusline+=%*
set statusline=\ %{toupper(mode())}\ [%n]\ %{mhi#sy_stats_wrapper()}\ %<%F\ %m\ %=\ %r\ %{prat#fugitive_status()}\ %=\ %{prat#ale_status()}\ %{toupper(strpart(&filetype,0,1)).strpart(&filetype,1)}\ %10(%l:%c/%L%)\ %4(%p%%%)\ %#error#%{prat#stl_tab_warning()}%{prat#stl_trailing_space_warning()}%*\%#errormsg#%{(&fenc!='utf-8'&&\&fenc!=''?'\ '.&fenc.'\ ':'')}%*
"
" }}}
" Better Shortcuts -------------------------------------------------------- {{{
"
" Better <C-^> hack !
" nnoremap <C-Tab> :buffers<CR>:b<Space>
nnoremap <C-Tab> :CtrlPBuffer<CR>
" ---------------------------------------------------------------------------
" with the default `:e` I'll have to remember the path of the file (which is hard)
" So, remap `:e` to run `:CtrlPMRUFiles`
" Pros : No need to remember the path, CtrlP will find it for you.
" Cons : Requires CtrlP (dependency) and
" commands that start with e will be hard to type.
" (You'll have to hit `:` and wait about a half a sec or so
" to start typing the command, starting with 'e')
nnoremap ;e :CtrlPMRUFiles<CR>
" ---------------------------------------------------------------------------
" clear serached stuff
nnoremap <C-S-c> :let @/=""<CR>
" ---------------------------------------------------------------------------
" Show syntax highlighting groups for word under cursor
" Thanks to Drew Neil from vimcasts
nmap <A-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" ---------------------------------------------------------------------------
" Returns cursor to last position before quitting
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
" ---------------------------------------------------------------------------
" Thanks to Steve Losh
" "Uppercase word" mapping.
"
" This mapping allows you to press <c-u> in insert mode to convert the current
" word to uppercase. It's handy when you're writing names of constants and
" don't want to use Capslock.
"
" To use it you type the name of the constant in lowercase. While your
" cursor is at the end of the word, press <c-u> to uppercase it, and then
" continue happily on your way:
"
" cursor
" v
" max_connections_allowed|
" <c-u>
" MAX_CONNECTIONS_ALLOWED|
" ^
" cursor
"
" It works by exiting out of insert mode, recording the current cursor location
" in the z mark, using gUiw to uppercase inside the current word, moving
" back to the z mark, and entering insert mode again.
"
" Note that this will overwrite the contents of the z mark. I never use it,
" but if you do you'll probably want to use another mark.
inoremap <C-u> <esc>mzgUiw`za
" ---------------------------------------------------------------------------
"}}}
" <F5> FileType Runners and Builders -------------------------------------- {{{
"
" Python {{{
augroup ft_python
au!
" Run the code in `%` (path/to/file) in python
" Damn the <leader>r in python-mode for python3
au Filetype python nnoremap <F5> :<C-u> ! python3 %<CR>
augroup END
"}}}
" LaTeX/Tex {{{
augroup ft_tex
au!
au Filetype tex nnoremap <F5> :<C-u>!pdflatex %<CR>
au Filetype tex nnoremap <F6> :<C-u>!xdg-open %:r."pdf"<CR>
augroup END
" }}}
" C {{{
augroup ft_c
au!
" Build the given .c file
" by giving `%` as the arg (which is path/to/file)
" and store the built binary file in the same path
"
" Best explained with example:
" Let's say file name is foo_bar.c
" Then, this makes it `:! gcc -Wall foo_bar.c -o foo_bar.c.o`
" (Slightly bad in naming the bin file ! ;) )
"
" This also works in this case.
" $ gvim ~/foo/bar/baz/dumb.c
" Then, this runs as:
" `:!gcc -Wall ~/foo/bar/baz/dumb.c -o ~/foo/bar/baz/dumb.c.o`
"
au Filetype c nnoremap <F5> :<C-u> ! gcc -Wall % -o %.o<CR>
augroup END
" }}}
" ---------------------------------------------------------------------------
" }}}
" Wild Ignore ------------------------------------------------------------- {{{
"
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.oo,*.obj,*.exe,*.dll " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
set wildignore+=*.class " Java Class files
set wildignore+=$VIMRUNTIME/doc/*.txt " Individual helpfiles
set wildignore+=$VIMRUNTIME/doc/*.tar.gz " compressed helpfiles
" For the `**` meaning, do a `:h starstar-wildcard`
set wildignore+=**/doc/*.txt
" ---------------------------------------------------------------------------
"}}}
" Auto Commands ----------------------------------------------------------- {{{
" General filetype {{{
" ---------------------------------------------------------------------------
" Resize splits when the window is resized
au VimResized * :wincmd =
" Show trailing space or tab warnings in the statusline
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
" ---------------------------------------------------------------------------
" }}}
" CSS {{{
au syntax css setlocal omnifunc=csscomplete#CompleteCSS
au syntax css setlocal completefunc=csscomplete#CompleteCSS
" }}}
" Python {{{
autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType *.py set textwidth=79 shiftwidth=4 tabstop=4 expandtab softtabstop=4 shiftround autoindent
au FileType python syn keyword pythonDecorator True None False self
" }}}
" HTML {{{
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
" }}}
" Better Completions {{{
" Thanks to Damian Conway for this
" prevent duplications of auto complete
augroup Undouble_Completions
autocmd!
autocmd CompleteDone * call Undouble_Completions()
augroup END
"
" }}}
" ---------------------------------------------------------------------------
" }}}
" Custom Functions -------------------------------------------------------- {{{
" Nyan cat {{{
command! NyanMe call NyanMe()
" ---------------------------------------------------------------------------
function! NyanMe()
hi NyanFur guifg=#BBBBBB
hi NyanPoptartEdge guifg=#ffd0ac
hi NyanPoptartFrosting guifg=#fd3699 guibg=#fe98ff
hi NyanRainbow1 guifg=#6831f8
hi NyanRainbow2 guifg=#0099fc
hi NyanRainbow3 guifg=#3cfa04
hi NyanRainbow4 guifg=#fdfe00
hi NyanRainbow5 guifg=#fc9d00
hi NyanRainbow6 guifg=#fe0000
echohl NyanRainbow1
echon "≈"
echohl NyanRainbow2
echon "≋"
echohl NyanRainbow3
echon "≈"
echohl NyanRainbow4
echon "≋"
echohl NyanRainbow5
echon "≈"
echohl NyanRainbow6
echon "≋"
echohl NyanRainbow1
echon "≈"
echohl NyanRainbow2
echon "≋"
echohl NyanRainbow3
echon "≈"
echohl NyanRainbow4
echon "≋"
echohl NyanRainbow5
echon "≈"
echohl NyanRainbow6
echon "≋"
echohl None
echo ""
echohl NyanRainbow1
echon "≈"
echohl NyanRainbow2
echon "≋"
echohl NyanRainbow3
echon "≈"
echohl NyanRainbow4
echon "≋"
echohl NyanRainbow5
echon "≈"
echohl NyanRainbow6
echon "≋"
echohl NyanRainbow1
echon "≈"
echohl NyanRainbow2
echon "≋"
echohl NyanRainbow3
echon "≈"
echohl NyanRainbow4
echon "≋"
echohl NyanRainbow5
echon "≈"
echohl NyanRainbow6
echon "≋"
echohl NyanFur
echon "╰"
echohl NyanPoptartEdge
echon "⟨"
echohl NyanPoptartFrosting
echon "⣮⣯⡿"
echohl NyanPoptartEdge
echon "⟩"
echohl NyanFur
echon "⩾^ω^⩽"
echohl None
echo ""
echohl NyanRainbow1
echon "≈"
echohl NyanRainbow2
echon "≋"
echohl NyanRainbow3
echon "≈"
echohl NyanRainbow4
echon "≋"
echohl NyanRainbow5
echon "≈"
echohl NyanRainbow6
echon "≋"
echohl NyanRainbow1
echon "≈"
echohl NyanRainbow2
echon "≋"
echohl NyanRainbow3
echon "≈"
echohl NyanRainbow4
echon "≋"
echohl NyanRainbow5
echon "≈"
echohl NyanRainbow6
echon "≋"
echohl None
echon " "
echohl NyanFur
echon "” ‟"
echohl None
sleep 1
redraw
echo " "
echo " "
echo "Noms?"
redraw
endfunction
" }}}
" Spell Checker ----------------------------------------------------------- {{{
if has("spell")
" turn spelling on by default
" set spell
" toggle spelling with F4 key
nnoremap <F7> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
" they were using white on white
highlight PmenuSel ctermfg=black ctermbg=lightgray
" limit it to just the top 10 items
set sps=best,10
endif
" }}}
" Better Completions function {{{
"
function! Undouble_Completions()
let col = getpos('.')[2]
let line = getline('.')
call setline('.', substitute(line, '\(\.\?\k\+\)\%' . col . 'c\zs\1', '', ''))
endfunction
"
" }}}
" ---------------------------------------------------------------------------
" }}}
" Plugin Settings --------------------------------------------------------- {{{
" Startify {{{
"
let g:startify_custom_indices = map(range(1,100), 'string(v:val)')
let g:startify_session_dir = '~/.vim/session'
let g:startify_bookmarks = [
\ '~/.Xresources',
\ '~/.vim/vimrc',
\ '~/.config/i3/config',
\ '~/.config/i3/i3status.conf'
\ ]
let g:startify_files_number = 8
let g:startify_change_to_dir = 0
let g:startify_change_to_vcs_root = 1
let g:startify_skiplist = [
\ '.git/COMMIT_EDITMSG',
\ '.gtkrc-2.0',
\ '/usr/share/vim/vim74/doc',
\ '/etc/*',
\ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') . 'doc',
\ 'bundle/.*/doc'
\ ]
let g:startify_relative_path = 1
let g:startify_update_oldfiles = 1
autocmd User Startified let &l:stl = ' Startify'
let g:startify_custom_header = []
let g:startify_list_order = [
\ [' MRU:'],
\ 'files',
\ [' Sess:'],
\ 'sessions',
\ [' Markers:'],
\ 'bookmarks'
\ ]
" }}}
" CtrlP {{{
" make CtrlP exclude these type of files from adding to MRUFiles cache
let g:ctrlp_mruf_exclude = '*.tar.gz\|bin|.git|*.srt|*.part|*.txt'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
let g:ctrlp_show_hidden = 1
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
" let g:ctrlp_user_command = 'ag %s -p /home/pratheek/.agignore -l --nocolor --hidden -g \""'
let g:ctrlp_user_command = 'rg %s --files -g ""'
" reuse startify window
let g:ctrlp_reuse_window = 'startify'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
" }}}
" SuperTab {{{
" let g:SuperTabDefaultCompletionType = \"<c-p>"
let g:SuperTabDefaultCompletionType = "<c-n>"
let g:SuperTabLongestHighlight = 1
let g:SuperTabCrMapping = 1
" }}}
" Vim-G (Search Google from G/Vim itself !) {{{
let g:vim_g_open_command = "xdg-open"
let g:vim_g_perl_command = "perl"
let g:vim_g_query_url = "http://google.co.in/search?q="
" }}}
" Signify {{{
let g:signify_sign_show_text = 0
" }}}
" Completor {{{
let g:completor_python_binary = '/usr/bin/python3'
let g:completor_completion_delay = 20
let g:completor_min_chars = 1
"}}}
" ALE {{{
" !!! Requires `autopep8`, `isort` to be installed
" !!! (might as well also have `flake8` installed)
let g:ale_fixers = {'python' : ['isort','autopep8']}
let g:ale_python_autopep8_options = '--aggressive'
let g:ale_fix_on_save = 1
let g:ale_lint_on_save = 1
let g:ale_sign_error = '❌'
" let g:ale_sign_warning = '❎'
" let g:ale_sign_warning = '◾⛔'
" let g:ale_sign_warning = '⭕'
" let g:ale_sign_warning = '🙈'
let g:ale_sign_warning = '🔹'
"}}}
" ---------------------------------------------------------------------------
"}}}
"
"
" vim:foldmethod=marker:foldlevel=0:textwidth=79