-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
584 lines (486 loc) · 17.5 KB
/
vimrc
File metadata and controls
584 lines (486 loc) · 17.5 KB
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
" Beguene's settings
" Author: Beguene Permale
" Version: 3.0
source $HOME/.vim/minimal.vim
filetype off
let g:ale_emit_conflict_warnings = 0
let g:vimsettings = '.vim/settings'
let vimplugged = '.vim/plugged'
function! LoadSettings(name)
let filename = $HOME . "/" . g:vimsettings . "/". a:name .".vimrc"
if filereadable(filename)
exec 'source ' . filename
endif
endfunction
" ******* Bundle ******* {{{
"------ START PLUGINS -------
if empty(glob("~/.vim/autoload/plug.vim"))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
auto VimEnter * PlugInstall
endif
call plug#begin()
"Colorscheme
Plug 'trevordmiller/nova-vim'
"Plug 'altercation/vim-colors-solarized'
Plug 'alnjxn/estilo-nova'
Plug 'sheerun/vim-polyglot'
Plug 'plasticboy/vim-markdown'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'itchyny/lightline.vim'
Plug 'scrooloose/nerdtree'
" Initialize plugin system
"File Mgt
Plug 'mhinz/vim-grepper'
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/neocomplete.vim'
end
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-abolish'
Plug 'milkypostman/vim-togglelist'
Plug 'Raimondi/delimitMate'
Plug 'junegunn/vim-easy-align'
Plug 'majutsushi/tagbar'
Plug 'mattn/emmet-vim'
Plug 'mileszs/ack.vim'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
"UI
Plug 'jszakmeister/vim-togglecursor'
" Easily use quickfix to search and replace bulk files
Plug 'terryma/vim-expand-region'
Plug 'tpope/vim-rails'
" Plug 'vim-ruby/vim-ruby'
Plug 'chrishunt/xterm-color-table.vim'
Plug 'w0rp/ale'
Plug 'neomake/neomake'
Plug 'rizzatti/dash.vim'
set rtp+=/usr/local/opt/fzf
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-repeat'
Plug 'chrisgillis/vim-bootstrap3-snippets'
Plug 'vimwiki/vimwiki'
Plug 'tpope/vim-dispatch'
Plug 'junegunn/gv.vim'
Plug 'junegunn/goyo.vim'
Plug 'tpope/vim-eunuch'
Plug 'AndrewRadev/splitjoin.vim' " add gS to smart split lines like comma lists and html tags
Plug 'TaDaa/vimade'
call LoadSettings('vimade')
call plug#end()
" }}}"
call LoadSettings('theme')
if has('autocmd')
filetype plugin indent on
endif
" ******* Files Opener ******* {{{
if isdirectory($HOME . "/.vim/plugged/fzf.vim") && !has("gui_running")
nnoremap <leader>p :FZF<CR>
" quick edit file, useful in log files to quickly go to the file
nnoremap <leader>e :FZF -1 -0 --query '<C-r>=expand("<cWORD>")<CR>'<CR>
let g:fzf_files_options =
\ '--preview "(highlight -O ansi {} || cat {}) 2> /dev/null | head -'.&lines.'"'
let g:fzf_buffers_jump = 1
nnoremap <leader>m :History<CR>
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_files_options =
\ '--preview "(highlight -O ansi {} || cat {}) 2> /dev/null | head -'.&lines.'"'
let g:fzf_layout = { 'down': '~70%' }
let g:fzf_buffers_jump = 1
let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'
let g:fzf_colors =
\ { "fg": ["fg", "Normal"],
\ "bg": ["bg", "Normal"],
\ "hl": ["fg", "CursorLine"],
\ "fg+": ["fg", "Underlined", "Underlined", "Underlined"],
\ "bg+": ["bg", "Underlined", "Underlined"],
\ "hl+": ["fg", "IncSearch"],
\ "info": ["fg", "DiffDelete"],
\ "border": ["fg", "Ignore"],
\ "prompt": ["fg", "Type"],
\ "pointer": ["fg", "IncSearch"],
\ "marker": ["fg", "IncSearch"],
\ "spinner": ["fg", "IncSearch"],
\ "header": ["fg", "IncSearch"] }
elseif isdirectory($HOME . "/.vim/plugged/ctrlp.vim")
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:20,results:20'
let g:ctrlp_working_path_mode = 2
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$\|\.yardoc\|public\/images\|data\|node_modules|log\|tmp$',
\ 'file': '\.exe$\|\.so$\|\.dat$|\.pyc$\|\.pyo$\|\.rbc$|\.rbo$\|\.class$\|\.o$\|\~$\'
\ }
"let g:ctrlp_max_height = 15
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
let g:ctrlp_clear_cache_on_exit = 0
"let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
if executable('ag')
let g:ctrlp_user_command='ag %s -l --nocolor -g ""'
endif
let g:ctrlp_open_multiple_files = '1rv'
let g:ctrlp_follow_symlinks = 1
let g:ctrlp_mruf_max = 500
let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*'
" let g:ctrlp_extensions = ['tag', 'buffertag','bookmarkdir', 'funky']
let g:ctrlp_dotfiles = 0
let g:ctrlp_switch_buffer = 0
let g:ctrlp_by_filename = 1
let g:ctrlp_mruf_default_order = 1
let g:ctrlp_mruf_exclude = '.git/*'
nnoremap <leader>p :CtrlP<CR>
nnoremap <leader>k :CtrlPBuffer<CR>
nnoremap <leader>m :CtrlPMRUFiles<CR>
else
endif
"}}}
" ******* TERMINAL SETTINGS *******
call LoadSettings('terminal')
" ******* Search *******
call LoadSettings('search')
" ******* Crypto ****** {{{
"silent! set cryptmethod=blowfish2
"vim -c 'set cm=blowfish2' -c w -c q file
" }}}
" ******* Navigation & Window *******
call LoadSettings('navigation')
" ******* Quickfix / Location List *******
call LoadSettings('quickfix')
"******* Language Specific ********* {{{
" PHP Generated Code Highlights (HTML & SQL)
"let php_sql_query=1
"let php_htmlInStrings=1
""For highlighting parent error ] or ): >
"let php_parent_error_close = 1
""For skipping an php end tag, if there exists an open ( or [ without a closing
"""one: >
"let php_parent_error_open = 1
let python_highlight_all=1
let javascript_enable_domhtmlcss=1
"JAVA
" Highlight functions using Java style
let java_highlight_functions="style"
" Don't flag C++ keywords as errors
let java_allow_cpp_keywords=1 "}}}"
call LoadSettings('system')
" ******* Status Line *******
call LoadSettings('lightline')
" ******* Files / Dir management ******* {{{
" :cd. change working directory to that of the current file
nnoremap <leader>k :Buffers<CR>
" Delete buffer on CtrlPBuffer
let g:ctrlp_buftag_types = {
\ 'javascript' : {
\ 'bin': 'jsctags',
\ 'args': '-f -',
\ }
\ }
" to be able to call CtrlP with default search text
function! CtrlPWithSearchText(search_text, ctrlp_command_end)
execute ':CtrlP' . a:ctrlp_command_end
call feedkeys(a:search_text)
endfunction
" CtrlP with default text
nmap ,wb :call CtrlPWithSearchText(expand('<cword>'), 'BufTag')<CR>
nmap ,wm :call CtrlPWithSearchText(expand('<cword>'), 'MRUFiles')<CR>
nmap ,wc :call CtrlPWithSearchText(expand('<cword>'), 'CmdPalette')<CR>
let g:ctrlp_by_filename = 1
" ******* Git / Fugitive *******
call LoadSettings('git')
" ******* Selection, Yank & Paste *******
call LoadSettings('selection')
" ******* Autocommands ******* {{{
if has("autocmd")
if $HOME !~# '^/Users/'
filetype off " Debian preloads this before the runtimepath is set
endif
" Java {{{
augroup ft_java
au!
au FileType java setlocal ai et sta sw=4 sts=4 cin
au FileType java setlocal foldmethod=marker
au FileType java setlocal foldmarker={,}
augroup END
" }}}
" CSS and LessCSS {{{
augroup ft_css
au!
au BufNewFile,BufRead *.less setlocal filetype=less
au Filetype less,css setlocal foldmethod=marker
au Filetype less,css setlocal foldmarker={,}
au Filetype less,css setlocal omnifunc=csscomplete#CompleteCSS
au Filetype less,css setlocal iskeyword+=-
au BufNewFile,BufRead *.less,*.css nnoremap <buffer> <localleader>S ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR>
" Make {<cr> insert a pair of brackets in such a way that the cursor is correctly
" positioned inside of them AND the following code doesn't get unfolded.
au BufNewFile,BufRead *.less,*.css inoremap <buffer> {<cr> {}<left><cr><space><space><space><space>.<cr><esc>kA<bs>
augroup END
augroup FTOptions " {{{2
" In Makefiles, use real tabs, not tabs expanded to spaces
autocmd FileType make setlocal noexpandtab
autocmd FileType vim setlocal ai et sta sw=2 sts=2 keywordprg=:help foldmethod=marker foldlevelstart=1
autocmd FileType sh,zsh,csh,tcsh inoremap <silent> <buffer> <C-X>! #!/bin/<C-R>=&ft<CR>
autocmd FileType perl,python,ruby inoremap <silent> <buffer> <C-X>! #!/usr/bin/<C-R>=&ft<CR>
" ###### TWIG
"au BufRead,BufNewFile *.html.twig set ft=html.twig syntax=htmltwig
au BufRead,BufNewFile *.html.twig setlocal expandtab sw=2 ts=2 sts=2 tw=0
" ###### CSS
autocmd BufNewFile,BufRead *.scss set ft=scss.css
autocmd BufNewFile,BufRead *.sass set ft=sass.css
autocmd BufNewFile,BufRead *.less set ft=less.css
" Other"
au BufRead,BufNewFile Gemfile set filetype=ruby
au BufRead,BufNewFile *.rabl setf ruby
au BufRead,BufNewFile *.md set filetype=markdown
"OmniFunc"
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
"autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType sql setlocal completefunc=sqlcomplete#Complete"
autocmd FileType * if exists("+omnifunc") && &omnifunc == "" | setlocal omnifunc=syntaxcomplete#Complete | endif
autocmd FileType * if exists("+completefunc") && &completefunc == "" | setlocal completefunc=syntaxcomplete#Complete | endif
" TXT
autocmd BufNewFile,BufRead *.txt,README,INSTALL,NEWS,TODO if &ft == ""|set ft=text|endif
autocmd BufNewFile,BufRead *.txt set ft=txt syntax=txt
autocmd FileType text,txt setlocal tw=79 linebreak nolist
autocmd FileType txt setlocal formatoptions=ctnqro comments+=n:*,n:#,n:•
augroup END "}}}2
augroup ft_javascript " {{{2
au!
autocmd FileType javascript silent! compiler node | setlocal makeprg=node\ %
autocmd FileType javascript setl fen nocindent
" au FileType javascript setlocal foldmethod=marker
" au FileType javascript setlocal foldmarker={,}
au FileType javascript setlocal sw=2 ts=2 sts=2 textwidth=79
autocmd BufNewFile,BufRead *.json set ft=javascript
autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json
augroup END "}}}
augroup ft_python " {{{2
au!
autocmd FileType python silent! compiler python | setlocal makeprg=python\ %
autocmd FileType python setlocal sw=4 ts=4 sts=4 textwidth=79 expandtab
augroup END "}}}
augroup ft_php " {{{2
au!
" run file with PHP CLI (CTRL-M)
autocmd FileType php noremap <F5> <esc>:w!<CR>:!php %<CR>
" PHP parser check (CTRL-L)
autocmd FileType php noremap <F4> <esc>:w!<CR>:!php -l %<CR>
autocmd FileType php setlocal sw=4 ts=4 sts=4 textwidth=79
augroup END "}}}
augroup ft_zsh " {{{2
au!
autocmd FileType zsh setlocal makeprg=zsh\ %
augroup END "}}}2
" ------------------------------------------------------------
" Ruby
" ------------------------------------------------------------
augroup ft_ruby " {{{2
autocmd!
"autocmd FileType ruby setlocal foldmethod=syntax
autocmd FileType ruby,eruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby setlocal ai et sta sw=2 sts=2
autocmd FileType ruby setlocal makeprg=ruby\ %
augroup END "}}}2
augroup ft_sh " {{{2
au!
autocmd FileType sh setlocal makeprg=sh\ %
"smart indent really only for C like languages
au FileType sh set nosmartindent autoindent
augroup END
augroup ft_html " {{{2
au!
au FileType html,xhtml,xml,eruby setlocal expandtab sw=2 ts=2 sts=2 tw=0
augroup END "}}}2
autocmd BufRead,BufNewFile *.erb set filetype=eruby.html
augroup Format " {{{2
au!
autocmd FileType c,cpp setlocal ai et sta sw=4 sts=4 cin
" HTML,xhtml,xml (tab width 2 chr, no wrapping)
autocmd FileType css setlocal sw=2 ts=2 sts=2 textwidth=79
autocmd FileType yaml setlocal ai et sta sw=2 sts=2
augroup END "}}}2
augroup Help " {{{2
au!
" Help File speedups, <enter> to follow tag, delete for back
au filetype help nnoremap <buffer><cr> <c-]>
au filetype help nnoremap <buffer><bs> <c-T>
au filetype help set nonumber
au FileType help wincmd _
augroup END "}}}2
autocmd FileType gitcommit setlocal spell
autocmd filetype svn,*commit* setlocal spell
endif " has("autocmd")}}}"
" ******* Custom Functions ******* {{{
call LoadSettings('custom')
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt() "{{{"
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction "}}}"
" BufferClose {{{
function! s:BufferClose()
exec "wincmd c"
endfunction " }}}
func! s:DeleteBuffer()
exec "bd" fnamemodify(getline('.')[2:], ':p')
exec "norm \<F5>"
endfunc
"}}}
" ******* Mappings ******* {{{
" Expand current buffer full window
"===============================================================================
" Function Key Mappings
"===============================================================================
"noremap <F2> :CtrlPSession<cr>
" <F4>: Save session
" F2 mgt sessions
" F4 lint
" F5 compile/make
" F6 run
nmap <F6> :w!<cr>:make<CR><CR><CR>:copen<CR><c-w><c-w>
"inoremap <C-L> <C-V>u2022<Space>
nnoremap <leader>bd :Bclose<cr>
call LoadSettings('spell')
" save as sudo
ca w!! w !sudo tee "%"
" CSS properties sort
nmap <leader>S /{/+1<CR>vi{:sort<CR>
" ******* Utilities ******* {{{
" Sort lines
nnoremap <leader>s vip:!sort<cr>
vnoremap <leader>s :!sort<cr>
" }}}
" }}}
call LoadSettings('vim-surround')
call LoadSettings('delimitMate')
autocmd FileType html,css EmmetInstall
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:20,results:20'
" PROFILING
call LoadSettings('profiling')
" Complete
call LoadSettings('autocomplete')
" TAGS {{{
"command! TagsRegenerate :NeomakeSh ctags -R --exclude=.git --exclude=log
" *** TAGLIST/TAGBAR ***
noremap <leader>l :TagbarToggle<CR>
let g:tagbar_autofocus = 1
" }}}
" ******* Linter ******* "{{{
call LoadSettings('ale')
let g:loaded_rrhelper = 1
let g:loaded_vimballPlugin = 1
"}}}
nnoremap <leader>d :Dash <C-r>=expand("<cword>")<CR><CR>
" FZF {{{
" Replace the default dictionary completion with fzf-based fuzzy completion
" Similarly, we can apply it to fzf#vim#grep. To use ripgrep instead of ag:
if executable('rg')
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
end
" }}}
" Mappings
call LoadSettings('mappings')
set suffixes+=.dvi " Lower priority in wildcards
" NOTES / WIKI
call LoadSettings('notes')
" Snippets
call LoadSettings('ultisnips')
" Command Line
call LoadSettings('command-line')
" select last paste in visual mode
nnoremap <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]'
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
" Better command history with q:
command! CmdHist call fzf#vim#command_history({'down': '40'})
" Better search history
command! QHist call fzf#vim#search_history({'down': '40'})
command! BBLines call fzf#vim#buffer_lines({'down': '~6'})
nnoremap \ :BBLines<cr>
set isfname-== " remove '=' from filename characters; for completion of FOO=/path/to/file"
set synmaxcol=1000 " don't syntax-highlight long lines (default: 3000)
function! TagOrGrep()
try
execute(":normal! \<C-]>")
catch
call fzf#vim#ag(expand('<cword>'))
endtry
endfunction
command! TagOrGrep :call TagOrGrep()
autocmd FileType ruby,eruby,python,javascript,php nnoremap <buffer> <cr> :TagOrGrep<cr>
" go to previous buffer
nnoremap <leader>v :b#<CR>
augroup filetypedetect
au! BufRead,BufNewFile *_spec.rb set filetype=ruby.rspec
augroup END
call LoadSettings('vim-easy-align')
" Very long lines will cause performance problems with Vim. One of the main
" culprits for this performance issue is the syntax highlighter
" set synmaxcol=200
autocmd BufNewFile,BufRead *.vue set filetype=html
function! DeleteEmptyBuffers()
let [i, n; empty] = [1, bufnr('$')]
while i <= n
if bufexists(i) && bufname(i) == ''
call add(empty, i)
endif
let i += 1
endwhile
if len(empty) > 0
exe 'bdelete' join(empty)
endif
endfunction
command! DeleteEmptyBuffers :call DeleteEmptyBuffers()
" TODO
" Remove Grepper, use only Fzf
" Make Ag from word from FzF a command line to save history
" K should always have quickfix full width (:bot copen)
nnoremap <leader>x :call fzf#vim#tags(expand('<cword>'), {'options': '--exact --select-1 --exit-0'})<CR>
nnoremap <leader>o :BTags<CR>
if has("gui_running")
cd ~/notes
end
set autowriteall
" Remove split bar separator
set fillchars+=vert:\
nmap <Leader>C :Commands<CR>
"
" ******* Experimental *******
source $HOME/.vim/experimental.vim