-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
718 lines (523 loc) · 20.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
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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
" =============================================================================
" Miller Medeiros .vimrc file
" -----------------------------------------------------------------------------
" heavily inspired by: @factorylabs, @scrooloose, @nvie, @gf3, @bit-theory.
" =============================================================================
" -----------------------------------------------------------------------------
" BEHAVIOR
" -----------------------------------------------------------------------------
set nocompatible " Disable vi compatibility
filetype on " filetype must be 'on' before setting it 'off'
" otherwise it exits with a bad status and breaks
" git commit.
filetype off " force reloading *after* pathogen loaded
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'wincent/Command-T'
Plugin 'vim-scripts/IndentAnything'
Plugin 'vim-scripts/IndexedSearch'
Plugin 'vim-scripts/LustyJuggler'
Plugin 'gregsexton/MatchTag'
Plugin 'vim-scripts/YankRing.vim'
Plugin 'mileszs/ack.vim'
Plugin 'vim-scripts/bufkill.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'sjl/gundo.vim'
Plugin 'sjl/clam.vim'
Plugin 'othree/html5.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'junkblocker/patchreview-vim'
Plugin 'ervandew/supertab'
Plugin 'scrooloose/syntastic'
Plugin 'godlygeek/tabular'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-speeddating'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'mhinz/vim-signify'
Plugin 'int3/vim-extradite'
Plugin 'flazz/vim-colorschemes'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'ryanoasis/vim-devicons'
Plugin 'maxboisvert/vim-simple-complete'
" css
Plugin 'ap/vim-css-color'
Plugin 'hail2u/vim-css3-syntax'
" js
Plugin 'pangloss/vim-javascript'
Plugin 'elzr/vim-json'
Plugin 'mxw/vim-jsx'
Plugin 'millermedeiros/vim-esformatter'
" Bundle 'marijnh/tern_for_vim'
" snipmate
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'
Plugin 'millermedeiros/vim-statline'
" Plugin 'bling/vim-airline'
" colorschemes
Plugin 'tomasr/molokai'
" Enable mouse use in all modes
set mouse=a
"Vim vim-airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" required for vundle
call vundle#end()
syntax on
filetype plugin indent on " enable detection, plugins and indent
" Local dirs (centralize everything)
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
" Change mapleader (easier to type), at the top since its used everywhere
let mapleader=","
let maplocalleader=";"
set spelllang=en_us " spell checking
set encoding=utf-8 nobomb " BOM often causes trouble, UTF-8 is awsum.
" --- performance / buffer ---
set hidden " can put buffer to the background without writing
" to disk, will remember history/marks.
set lazyredraw " don't update the display while executing macros
set ttyfast " Send more characters at a given time.
" --- history / file handling ---
set history=999 " Increase history (default = 20)
set undolevels=999 " Moar undo (default=100)
set autoread " reload files if changed externally
" --- backup and swap files ---
" I save all the time, those are annoying and unnecessary...
set nobackup
set nowritebackup
set noswapfile
" --- search / regexp ---
set gdefault " RegExp global by default
set magic " Enable extended regexes.
set hlsearch " highlight searches
set incsearch " show the `best match so far' astyped
set ignorecase smartcase " make searches case-insensitive, unless they
" contain upper-case letters
" --- keys ---
set backspace=indent,eol,start " allow backspacing over everything.
set esckeys " Allow cursor keys in insert mode.
set nostartofline " Make j/k respect the columns
" set virtualedit=all " allow the cursor to go in to 'invalid' places
set timeoutlen=500 " how long it wait for mapped commands
set ttimeoutlen=100 " faster timeout for escape key and others
" Use a bar-shaped cursor for insert mode, even through tmux.
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" -----------------------------------------------------------------------------
" UI
" -----------------------------------------------------------------------------
set t_Co=256 " 256 colors terminal
let g:molokai_original=0
colorscheme molokai
" make 'var' keyword easier to spot
hi link javascriptType Keyword
" default ColorColumn is too distractive
hi clear ColorColumn
hi link ColorColumn FoldColumn
" defaul line number is too distractive
hi clear LineNr
hi link LineNr Comment
hi link OverLength Error
" --- UI settings ---
if has('gui_running')
set guifont=MelsoLGDZ Nerd\ Font:h16
set gfn:MelsoLGDZ Nerd\ Font:h16
set transp=0
" toolbar and scrollbars
set guioptions-=T " remove toolbar
set guioptions-=L " left scroll bar
set guioptions-=r " right scroll bar
set guioptions-=b " bottom scroll bar
set guioptions-=h " only calculate bottom scroll size of current line
set shortmess=atI " Don't show the intro message at start and
" truncate msgs (avoid press ENTER msgs).
endif
set cursorline " Highlight current line
set laststatus=2 " Always show status line
set number " Enable line numbers.
set numberwidth=5 " width of numbers line (default on gvim is 4)
set report=0 " Show all changes.
set showmode " Show the current mode.
set showcmd " show partial command on last line of screen.
set showmatch " show matching parenthesis
set splitbelow splitright " how to split new windows.
set title " Show the filename in the window title bar.
set scrolloff=5 " Start scrolling n lines before horizontal
" border of window.
set sidescrolloff=7 " Start scrolling n chars before end of screen.
set sidescroll=1 " The minimal number of columns to scroll
" horizontally.
" add useful stuff to title bar (file name, flags, cwd)
" based on @factorylabs
if has('title') && (has('gui_running') || &title)
set titlestring=
set titlestring+=%f
set titlestring+=%h%m%r%w
set titlestring+=\ -\ %{v:progname}
set titlestring+=\ -\ %{substitute(getcwd(),\ $HOME,\ '~',\ '')}
endif
" use relative line number by default
if exists('+relativenumber')
set relativenumber
endif
" --- command completion ---
set wildmenu " Hitting TAB in command mode will
set wildchar=<TAB> " show possible completions.
set wildmode=list:longest
set wildignore+=*.DS_STORE,*.db,node_modules/**,*.jpg,*.png,*.gif
" --- diff ---
set diffopt=filler " Add vertical spaces to keep right
" and left aligned.
set diffopt+=iwhite " Ignore whitespace changes.
" --- folding---
set foldmethod=manual " manual fold
set foldnestmax=3 " deepest fold is 3 levels
set nofoldenable " don't fold by default
" --- list chars ---
" list spaces and tabs to avoid trailing spaces and mixed indentation
" see key mapping at the end of file to toggle `list`
set listchars=tab:▹\ ,trail:·,nbsp:⚋
set fillchars=fold:-
set list
" --- remove sounds effects ---
set noerrorbells
set visualbell
" -----------------------------------------------------------------------------
" INDENTATION AND TEXT-WRAP
" -----------------------------------------------------------------------------
set expandtab " Expand tabs to spaces
set autoindent smartindent " auto/smart indent
set copyindent " copy previous indentation on auto indent
set softtabstop=2 " Tab key results in # spaces
set tabstop=2 " Tab is # spaces
set shiftwidth=2 " The # of spaces for indenting.
set smarttab " At start of line, <Tab> inserts shift width
" spaces, <Bs> deletes shift width spaces.
set wrap " wrap lines
set textwidth=80
"set colorcolumn=+1 " Show large lines
set formatoptions=qrn1 " automatic formating.
set formatoptions-=o " don't start new lines w/ comment leader on
" pressing 'o'
set nomodeline " don't use modeline (security)
set pastetoggle=<leader>p " paste mode: avoid auto indent, treat chars
" as literal.
" -----------------------------------------------------------------------------
" PLUGINS
" -----------------------------------------------------------------------------
" --- NERDTree ----
let NERDTreeIgnore=['.DS_Store']
let NERDTreeShowBookmarks=0 "show bookmarks on startup
let NERDTreeHighlightCursorline=1 "Highlight the selected entry in the tree
let NERDTreeShowLineNumbers=0
let NERDTreeMinimalUI=1
autocmd vimenter * NERDTree
noremap <leader>nt :NERDTreeToggle<CR>
" --- NERDCommenter ---
let NERDSpaceDelims=1 " space around delimiters
let NERDRemoveExtraSpaces=1
let g:NERDCustomDelimiters = {
\ 'scss': { 'left': '//' }
\ }
" --- Syntastic : Linting / Error check ---
let g:syntastic_auto_loc_list=2
let g:syntastic_check_on_open=1
" close/open location list (errors)
noremap <silent><leader>lc :lcl<CR>
noremap <silent><leader>lo :Errors<CR> :lw<CR>
noremap <silent><leader>ln :lnext<CR>
noremap <silent><leader>lp :lprev<CR>
" --- autocomplete / supertab / jscomplete ---
set infercase
set completeopt=longest,menuone
set omnifunc=syntaxcomplete#Complete
set completefunc=syntaxcomplete#Complete
set complete=.,w,b,u,U,t,i,d
" see [autocommands] at the end for more autocomplete settings
" nodejs-complete / jscomplete
let g:node_usejscomplete = 1
let g:jscomplete_use = ['dom', 'moz']
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-Space>'
let g:SuperTabLongestEnhanced = 1
let g:SuperTabDefaultCompletionType = "<c-p>"
" --- snipmate ---
let g:snips_author = 'Miller Medeiros'
" --- EasyMotion ---
let g:EasyMotion_leader_key = '<Leader>m'
" lets make <leader>F and <leader>f use easymotion by default
let g:EasyMotion_mapping_f = '<leader>f'
let g:EasyMotion_mapping_F = '<leader>F'
" --- Strip trailing whitespace ---
function! StripWhitespace ()
let save_cursor = getpos(".")
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
" Trailing white space (strip spaces)
noremap <leader>ss :call StripWhitespace()<CR>
" --- matchit ---
runtime macros/matchit.vim " enable matchit (better '%' key mapping)
" --- vim-css-color ---
let g:cssColorVimDoNotMessMyUpdatetime = 1
" --- vim-signify ---
let g:signify_update_on_focusgained = 1
" --- Command-T ---
let g:CommandTMaxFiles=2000
let g:CommandTMaxHeight=12
noremap <silent> <leader>tt :CommandT<CR>
noremap <silent> <leader>bt :CommandTBuffer<CR>
noremap <silent> <leader>tf :CommandTFlush<CR>
" --- LustyJuggler ---
let g:LustyJugglerSuppressRubyWarning = 1 " avoid error if running on terminal
" --- statline ---
" errors color
hi User3 guifg=#FFFFFF guibg=#FF0000 gui=bold ctermfg=15 ctermbg=1 cterm=bold
let g:statline_fugitive = 1
let g:statline_filename_relative = 1
let g:statline_mixed_indent_string = '[mix]'
" --- gundo ---
nnoremap <leader>gu :GundoToggle<CR>
let g:gundo_right = 1
let g:gundo_preview_bottom = 1
" --- toggle indentation mode ---
function! ToggleExpandTab()
if &et
set noet softtabstop=0
else
execute "set et softtabstop=". &tabstop
endif
endfunction
noremap <silent> <leader>et :call ToggleExpandTab()<CR>
" --- Show syntax highlighting groups for word under cursor ---
" http://vimcasts.org/episodes/creating-colorschemes-for-vim/
nnoremap <leader>sh :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" faster wehn opening files with large lines
set synmaxcol=300
" --- Highlight word under cursor ---
" hi W1 guibg=#aeee00 guifg=#000000 ctermbg=154 ctermfg=16
" nnoremap <silent> <leader>h1 :execute 'match W1 /\<<c-r><c-w>\>/'<cr>
" --- Tabular.vim ---
noremap <silent> <leader>t: :Tabularize /:<CR>
noremap <silent> <leader>t= :Tabularize /=<CR>
noremap <silent> <leader>t, :Tabularize /,<CR>
noremap <silent> <leader>t{ :Tabularize /{<CR>
noremap <silent> <leader>t" :Tabularize /"<CR>
noremap <silent> <leader>t' :Tabularize /'<CR>
noremap <silent> <leader>t[ :Tabularize /[<CR>
noremap <silent> <leader>t/ :Tabularize ///<CR>
noremap <silent> <leader>t\| :Tabularize /\|<CR>
" --- include content of static files ---
" borrowed from: http://vim.1045645.n5.nabble.com/vim-counterpart-for-persistent-includes-td4276915.html
function! IncludeStatic()
:g/<!-- #include "[^"]*" -->\_.\{-}<!-- end include -->/let fname = matchstr(getline('.'),'<!-- #include "\zs[^"]*\ze" -->')|exec '+,/<!-- end include -->/-!cat '.fnameescape(fname)
endfunction
noremap <silent> <leader>ic :call IncludeStatic()<CR>
" --- convert selected text from markdown to HTML ---
vnoremap <silent> <leader>md :! mdown<CR>
function! SanitizeMdown()
%s/<\/\?p>//
%s/<br \?\/\?>/ /
%s/<pre><code>/<pre class="brush:js">\r/
%s/<\/code><\/pre>/<\/pre>/
endfunc
noremap <silent> <leader>mds :call SanitizeMdown()<CR>
" --- format JavaScript source code using esformatter --
nnoremap <silent> <leader>es :Esformatter<CR>
vnoremap <silent> <leader>es :EsformatterVisual<CR>
" --- toggle autocomplete behavior and word delimiters ---
function! KeywordsAll()
setl iskeyword=@,48-57,192-255,\@,\$,%,-,_
endfunc
function! KeywordsBasic()
setl iskeyword=@,48-57,192-255
endfunc
" --- visual block move ---
" http://www.youtube.com/watch?v=aHm36-na4-4#t=35m10
let g:DVB_TrimWS = 1
vmap <expr> <S-LEFT> DVB_Drag('left')
vmap <expr> <S-RIGHT> DVB_Drag('right')
vmap <expr> <S-DOWN> DVB_Drag('down')
vmap <expr> <S-UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
" --- transform lists ---
" http://www.youtube.com/watch?v=aHm36-na4-4#t=17m30
nmap <leader>ls :call ListTrans_toggle_format()<CR>
vmap <leader>ls :call ListTrans_toggle_format('visual')<CR>
" -----------------------------------------------------------------------------
" KEY MAPPINGS
" -----------------------------------------------------------------------------
" mapleader set at the top of the file to avoid conflicts
" --- FIX/IMPROVE DEFAULT BEHAVIOR ---
" faster commands
" nnoremap <space> :
" sudo write
" command! W w !sudo tee % > /dev/null
" Swap v and CTRL-V, because Block mode is more useful that Visual mode
" nnoremap v <C-V>
" nnoremap <C-V> v
" vnoremap v <C-V>
" vnoremap <C-V> v
" avoid mistyping commands
command! W w
command! Wq wq
command! Bd bd
" Split line (sister to [J]oin lines)
" The normal use of S is covered by cc, so don't worry about shadowing
nnoremap S i<cr><esc><right>
" movement by screen line instead of file line (for text wrap)
nnoremap j gj
nnoremap <down> gj
nnoremap k gk
nnoremap <up> gk
" next tab
nnoremap <C-Tab> :tabn<CR>
" automatic esc, really uncommon to type jj,jk
inoremap jj <ESC>
inoremap jk <Esc>
" Faster scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Bubble single lines, similar to Eclipse (requires unimpaired.vim)
nmap <C-Up> [e
nmap <C-Down> ]e
" Bubble multiple lines, similar to Eclipse (requires unimpaired.vim)
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Duplicate lines, similar to Eclipse
noremap <C-S-Up> YP
noremap <C-S-Down> YP
" 'fix' search regexp to be compatible with Perl format
" nmap / /\v
" vmap / /\v
" Use the damn hjkl keys
" noremap <up> <nop>
" noremap <down> <nop>
" noremap <left> <nop>
" noremap <right> <nop>
" improve the 'search word under cursor' behavior
nnoremap * :silent call KeywordsAll()<CR> *
nnoremap # :silent call KeywordsAll()<CR> #
" --- COMMON STUFF / HELPERS ---
" Toggle show tabs and trailing spaces
nnoremap <leader>c :set nolist!<CR>
" Clear the search highlight
nnoremap <silent> \ :silent nohlsearch<CR>
" text wrap: Hard wrap paragraph text (similar to TextMate Ctrl+Q)
nnoremap <leader>tw gqip
nnoremap <leader>nw :set nowrap<CR>
" Open file (useful for HTML)
noremap <silent> <leader>o :!open %<CR>
" Reformat code
nnoremap <leader>rf gg=G
" I use retab too much and it's hard to type
nnoremap <leader>rt :retab!<CR>
" Pull word under cursor into LHS of a substitute (find and replace)
nnoremap <leader>rr :silent call KeywordsAll()<CR> :%s#\<<C-r>=expand("<cword>")<CR>\>#
" Insert/append a single character
" noremap ,, i_<esc>r
" noremap ;; a_<esc>r
" Visually select the text that was last edited/pasted
nnoremap <leader>v `[v`]
" fast Ack
nnoremap <leader>a :tab split<CR>:Ack<Space>
nnoremap <leader>aw :silent call KeywordsAll()<CR> :tab split<CR>:Ack<cword><CR> :silent call KeywordsBasic()<CR>
" Toggle spelling hints
nnoremap <silent> <leader>ts :set spell!<CR>
" Move between splits (windows)
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" Move windows around (only works on same row)
noremap <C-S-Right> <C-w>r
noremap <C-S-Left> <C-w>R
" Open current buffer in a new split
noremap <leader>s :vsplit<cr>
noremap <leader>i :split<cr>
" close window
noremap <leader>q :clo<CR>
" delete buffer but keep window open (requires bufkill.vim)
map <leader>bd :BD<CR>
" smarter next/prev buffer (requires bufkill.vim)
map <leader>bn :BF<CR>
map <leader>bp :BB<CR>
" resize splits (http://vim.wikia.com/wiki/Resize_splits_more_quickly)
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
" add spaces inside current parenthesis
map <leader>( vi(xi P
" -----------------------------------------------------------------------------
" FILE HANDLING
" -----------------------------------------------------------------------------
" [autocommands] borrowed from @bit-theory vimfiles and edited
augroup mm_buf_cmds
" clear commands before resetting
autocmd!
" when vimrc is edited, reload it
autocmd bufwritepost .gvimrc source %
autocmd bufwritepost .vimrc source %
" Only show cursorline in the current window and in normal mode
au WinLeave,InsertEnter * set nocul
au WinEnter,InsertLeave * set cul
" filetype
autocmd BufNewFile,BufRead *.json setf json
autocmd BufNewFile,BufRead *.hx setf haxe
autocmd FileType mustache runtime! ftplugin/html/sparkup.vim
" Enable omnicomplete for supported filetypes
autocmd FileType css,scss setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
" autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" jscomplete is a separate plugin
autocmd FileType javascript setlocal omnifunc=jscomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" make `gf` search for .js files
autocmd FileType javascript setlocal suffixesadd=.js
autocmd FileType javascript setlocal path+=js,scripts
" make sure `complete` works as expected for CSS class names without
" messing with motions (eg. '.foo-bar__baz') and we make sure all
" delimiters (_,-,$,%,.) are treated as word separators outside insert mode
autocmd InsertEnter,BufLeave * :silent call KeywordsAll()
autocmd InsertLeave,BufEnter * :silent call KeywordsBasic()
" yes, we need to duplicate it on VimEnter for some weird reason
autocmd VimEnter * nnoremap * :silent call KeywordsAll()<CR> *
autocmd VimEnter * nnoremap # :silent call KeywordsAll()<CR> #
" Toggle relative/absolute line numbers during edit
" if exists('+relativenumber')
" autocmd InsertEnter * setl nu
" autocmd InsertLeave,BufEnter * setl rnu
" endif
" highlight char at column 81 (textwidth + 1)
autocmd BufEnter * match OverLength /\%81v/
" Color Column (only on insert)
if exists("&colorcolumn")
autocmd InsertEnter * set colorcolumn=80
autocmd InsertLeave * set colorcolumn=""
endif
augroup END