-
Notifications
You must be signed in to change notification settings - Fork 3
/
.vimrc
689 lines (587 loc) · 21.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
set encoding=utf-8
scriptencoding utf-8
" Pathogen --- {{{
" I'm no longer using Pathogen and am instead using
" native package loading which was introduced in Vim 8.
" It automatically loads all plugins found in
" ~/.vim/pack/plugins/start where "plugins" can have any name.
" For more details, see https://shapeshed.com/vim-packages/.
"call pathogen#infect() " installs plugins found in ~/.vim/bundle
" Generate documentation from files in each directory in runtimepath.
" To see a list of these directories, enter :set runtimepath
"call pathogen#helptags()
" }}}
" Miscellaneous options {{{
" Enable syntax highlighting.
" background must be set before "syntax on"!
"set background=light
set background=dark
syntax on
set antialias
set clipboard=unnamed " yank (copy) and delete (cut) also go to system clipboard
"set cursorline " underlines current line so it is easy to see - off for ScreenFlow
" To get word completion using dictionary while in insert mode,
" type some letters and press c-x c-k.
set dictionary=/usr/share/dict/words
set dictionary+=~/.vim/computer-words
"set guifont=Monaco:h14
"set guifont=Inconsolata:h18 " font used in GUI-version of Vim
"set guifont=Inconsolata\ for\ Powerline:h15
set guifont=Consolas
set hlsearch " highlight all search matches, not just the first
set incsearch " use incremental searching
set mouse=a " enable use of mouse in all modes
" Prevent files from being modified twice on save which is a problem for gulp watch.
" See http://stackoverflow.com/questions/21608480/gulp-js-watch-task-runs-twice-when-saving-files.
set nobackup
"set nocompatible " running vim, not vi, so don't force vi compatibility
set noshowmode " since it is already being displayed in the status bar by airline
set number
" set relativenumber " turn off when creating ScreenFlow videos
set term=screen-256color
set updatetime=750
set wildmode=list:longest,full " gives tab completion lists in ex command area
runtime macros/matchit.vim
" Don't need this since it is specified in status line config.
"set ruler " show line and column number of cursor position
" Highlight column 81 in lines that exceed 80.
" 100 is a priority.
highlight ColorColumn ctermbg=red
call matchadd('ColorColumn', '\%81v', 100)
" netrw list style (toggle by pressing i)
let g:netrw_liststyle=3 " use tree mode as default view
"set lazyredraw
set list
" Render tab characters with a right-pointing double angle
" followed by middle dots to show where the tab stop ends.
" Render trailing spaces with middle dots.
set listchars=tab:»·,trail:·
" }}}
" Abbreviations --- {{{
iabbrev @@ [email protected]
iabbrev rmv R. Mark Volkmann
" }}}
" Indentation and Tabs --- {{{
filetype plugin indent on " enable language-dependent indentation
set cindent " enable source code indentation
" (1s means indent lines after an open paren by 1 shiftwidth. Default is " (2s.
set cinoptions=(1s
set shiftwidth=2 " indent code with two spaces
set tabstop=2 " tabs take two spaces
set softtabstop=2 " tabs take two spaces
set expandtab " replace tabs with spaces
set smarttab " pressing tab key in insert mode insert spaces
set shiftround " round indent to multiples of shiftwidth
" }}}
" Colors --- {{{
set t_Co=256 " number of colors " number of colors
" See color codes in MyUnixEnv/notes/vim-cterm-colors.png.
hi! DiffAdd ctermbg=22 " green for lines added
hi! DiffChange ctermbg=54 " purple for lines that were changed
hi! DiffDelete ctermbg=88 " red for lines removed
hi! DiffText ctermbg=18 " blue for parts of lines that were changed
"set t_AB=^[[48;5;%dm " set background color
"set t_AF=^[[38;5;%dm " set foreground color
"colorscheme torte
"colorscheme desert
"colorscheme volkmann
"colorscheme Tomorrow
"let g:solarized_termcolors=256
"let g:solarized_termtrans=1
"colorscheme solarized
" To enable italics, see
" https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/
set t_ZH=[3m
set t_ZR=[23m
" These work with .vim/syntax/javascript.vim.
hi Boolean ctermfg=172 " orange
hi Class ctermfg=12 " blue
hi Comment ctermfg=42 cterm=italic " green
hi Function ctermfg=9 " red
hi Keyword ctermfg=191 " yellow
hi Normal ctermfg=7 " light gray
hi Number ctermfg=172 " orange
hi Operator ctermfg=163 " purple
hi Reserved ctermfg=1 ctermbg=8 " red on gray
hi Search cterm=underline ctermfg=15 ctermbg=0 " white on black
hi Semicolon ctermfg=8 " gray
hi String ctermfg=172 " orange
hi Tag ctermfg=90 " purple
hi This ctermfg=87 " light blue
hi Todo ctermbg=1 ctermfg=15 " white on red
hi cssAuralAttr ctermfg=15 " white
hi cssBoxAttr ctermfg=15 " white
hi cssBoxProp ctermfg=191 " yellow
hi cssClassName ctermfg=12 " blue
hi cssColor ctermfg=15 " white
hi cssColorProp ctermfg=191 " yellow
hi cssCommonAttr ctermfg=15 " white
hi cssBoxProp ctermfg=191 " yellow
hi cssDefinition ctermfg=191 " yellow
hi cssFontAttr ctermfg=15 " white
hi cssIdentifier ctermfg=172 " orange
hi cssPagingProp ctermfg=15 " white
hi cssRenderAttr ctermfg=15 " white
hi cssRenderProp ctermfg=191 " yellow
hi cssTableAttr ctermfg=15 " white
hi cssTableProp ctermfg=191 " yellow
hi cssTagName ctermfg=9 " red
hi cssTextAttr ctermfg=15 " white
hi cssTextProp ctermfg=191 " yellow
hi cssValueLength ctermfg=15 " white
hi cssValueNumber ctermfg=15 " white
hi cssUIAttr ctermfg=15 " white
hi cssUIProp ctermfg=191 " yellow
hi lessComment ctermfg=22 cterm=italic " green
hi lessVariable ctermfg=13 " magenta
hi htmlArg ctermfg=8 " dark gray; attribute names
hi htmlEndTag ctermfg=1 " red
hi htmlHead ctermfg=191 " yellow
hi htmlString ctermfg=15 " white
hi htmlTag ctermfg=2 " green; start tag
hi htmlTagName ctermfg=191 " yellow
hi htmlTitle ctermfg=15 " white
hi lineNr ctermfg=21 " blue
hi cursorLineNr ctermfg=12 " blue
" }}}
" Command-T plugin setup for fast file navigation {{{
"let g:CommandTCancelMap=['<ESC>', '<c-c>']
"let g:CommandTSelectNextMap=['<c-n>', 'j', '<DOWN>']
"let g:CommandTSelectPrevMap=['<c-p>', 'k', '<UP>']
" }}}
" Key mappings --- {{{
" To see all normal mode mappings, :map
" To see all insert mode mappings, :imap
" toggles
let mapleader = ','
" dictionary word completion
" Press ctrl-n and ctrl-p to traverse list of matching words.
inoremap <leader>d <c-x><c-k>
" edit .vimrc
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" configure use of splits
set splitbelow
set splitright
nnoremap <c-j> <c-w><c-j>
nnoremap <c-k> <c-w><c-k>
nnoremap <c-l> <c-w><c-l>
nnoremap <c-h> <c-w><c-h>
" source .vimrc
nnoremap <leader>sv :source $MYVIMRC<cr>
" show syntax groups for token under cursor
nnoremap <leader>sg :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
" toggle search highlighting
nnoremap <leader>h :set hlsearch! hlsearch?<cr>
" toggle line numbering between relative, absolute, and none
function! NumberToggle()
if (&relativenumber == 1) " turn number on and relative off
set number
set norelativenumber
elseif (&number == 1) " turn both off
set nonumber
set norelativenumber
else " turn both on
set number
set relativenumber
endif
endfunc
"nnoremap <leader>n :setlocal number!<cr>
nnoremap <leader>n :call NumberToggle()<cr>
" replace all occurences of the complete word under the cursor
"nnoremap <leader>r :%s/\<<c-r><c-w>\>/
" Switching buffers
" Use C-^ to toggle to last buffer
nnoremap <left> :bprev<cr>
nnoremap <right> :bnext<cr>
" Move up or down by a screen line, not a physical line.
" These differ when text wraps.
nnoremap <down> gj
nnoremap <up> gk
" Quick pairs
inoremap <leader>' ''<esc>i
inoremap <leader>" ""<esc>i
inoremap <leader>( ()<esc>i
inoremap <leader>[ []<esc>i
inoremap <leader>{ {}<esc>i
" Add semicolon to end of line
nnoremap <leader>; A;<esc>
inoremap <leader>; <esc>A;
" Reformat entire file using formatprg for the file type.
nnoremap <leader>f ggVGgq
" save buffer (requires stty -ixon in .bashrc)
" In insert mode, <c-o> escapes to normal mode for one command
" and then switches back to insert mode.
inoremap <c-s> <c-o>:update<cr>
nnoremap <c-s> :update<cr>
" Source the current buffer
nnoremap <leader>sb :source %<cr>
" Macros {{{
let @a='i<a href="lv$hyA">kjpa</a>'
" Enter insert mode, insert <code>, exit insert mode,
" find the next space, comma, period, or end of line,
" turn off highlighting,
" enter insert mode, insert </code>, and exit insert mode.
let @c='i<code>/ \|,\|\.\|<\|$:nohi</code>'
" Same as @c, but inserts <i> tags instead of <code>.
let @i='i<i>/ \|,\|\.\|<\|$:nohi</i>'
" }}}
" Simplify key mapping for omnifunc completion.
inoremap <leader>c <c-x><c-o>
" Allow insert mode completion with tab key in addition to ctrl-n.
" Can't do this because it conflicts with Snipmate!
"imap <tab> <c-n>
"ino <c-j> <c-r>=TriggerSnippet()<cr>
"snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
" CtrlP mappings - full path fuzzy file, buffer, mru, tag, ... finder
" I'm no longer using CtrlP and am using FZF instead.
" It's configured to be invoked with ctrl-p.
"let g:ctrlp_map = '<c-p>'
"let g:ctrlp_cmd = 'CtrlP .'
"let g:ctrlp_working_path_mode='c'
nmap <c-p> :FZF!<cr>
" ctrlp-funky mappings
" To get a list of all functions in current file,
" select one in quickfix list using arrow keys,
" and press return to go to it ...
nnoremap <leader>fu :CtrlPFunky<cr>
" To go to the definition of the function name under the cursor ...
" (still have to press return in quickfix list)
nnoremap <leader>fU :execute 'CtrlPFunky ' . expand('<cword>')<cr>
" EasyMotion mappings
" Search for beginning of a word in both directions.
map <leader>w <plug>(easymotion-bd-w)
" Search for beginning of a word in all windows. Why doesn't this work?
"nmap <leader>w <plug>(easymotion-overwin-w)
" Emmet settings - HTML and CSS shortcuts
"let g:user_emmet_install_global = 0 " don't enable for all file types
"autocmd FileType html,css EmmetInstall " specify file types
" Default trigger key is ctrl-y followed by comma.
let g:user_emmet_leader_key='<C-e>'
let g:user_emmet_settings = {'javascript.jsx': {'extends': 'jsx'}}
let g:user_emmet_install_global = 0
autocmd FileType html,css,javascript.jsx,scss EmmetInstall
" Printing using enscript (these aren't working yet)
noremap <leader>e1 execute "normal! '<,'>:w !enscript --borders --fancy-header --line-numbers=1 --mark-wrapped-lines=arrow --pretty-print=cpp -L63"
noremap <leader>e2 execute "normal! '<,'>:w !enscript --borders --columns-2 --fancy-header --line-numbers=1 --mark-wrapped-lines=arrow --pretty-print=cpp"
" }}}
" Haskell
let g:hindent_on_save = 0
nnoremap <Leader>ht :GhcModType<cr>
nnoremap <Leader>htc :GhcModTypeClear<cr>
autocmd FileType haskell nnoremap <buffer> <leader>? :call ale#cursor#ShowCursorDetail()<cr>
" JavaScript and JSX syntax highlighting
" Enable syntax highlighting for Flow.
let g:javascript_plugin_flow = 1
" Enable syntax highlighting in jsdoc comments.
let g:javascript_plugin_jsdoc = 1
" Enable JSX syntax highlighting in files with a .jsx extension instead of .js.
let g:jsx_ext_required = 0
" The Silver Searcher (ag) --- {{{
if executable('ag')
" Use ag instead of grep.
set grepprg=ag\ --nogroup\ --nocolor\ --column
set grepformat=%f:%l:%c:\ %m
" Use ag in CtrlP for listing files.
" It is lightning fast and respects .gitignore.
"let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache.
"let g:ctrlp_use_caching = 0
endif
" }}}
" Spell checking --- {{{
"set nospell " start with spell checking off
"setlocal nospell " start with spell checking off
" Use dictionary of Vim's spell checker.
" It takes a couple of seconds for these to take effect.
" insert-mode toggle only for current buffer
inoremap <leader>s <c-o>:setlocal spell! spelllang=en_us<cr>
" normal-mode toggle only for current buffer
nnoremap <leader>s :setlocal spell! spelllang=en_us<cr>
nnoremap <leader>S i<c-x>s
"highlight SpellBad term=reverse ctermbg=7
highlight clear SpellBad
" This is also used for lines that ESLint marks as containing errors.
highlight SpellBad ctermfg=black ctermbg=red
set thesaurus=~/.vim/mthesaur.txt
" TypeScript --- {{{
autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript
" }}}
" Folding --- {{{
" See VimNotes.txt for fold-related key commands.
augroup javaScript
autocmd!
"autocmd FileType javascript set foldmethod=syntax
" JavaScript folding is now configured in .vim/ftplugins/javascript.vim.
"autocmd FileType javaScript :set fmr=/**,*/ fdm=marker fdc=1
"set syntax=javaScript
set foldmethod=syntax
"set foldlevel=1
"let javaScript_fold=1
set nofoldenable
" Prettier JavaScript formatting
"autocmd FileType javascript setlocal formatprg=prettier-eslint\ --stdin
autocmd FileType javascript setlocal formatprg=prettier\ --stdin
autocmd FileType typescript setlocal formatprg=prettier\ --stdin
" Automatically format JavaScript code before it is saved.
" silent! is needed to avoid message "No write since last change".
"autocmd BufWritePre *.js exe "silent! normal! gggqG\<C-o>\<C-o>"
"autocmd BufWritePre *.js? :normal gggqG
augroup END
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
nnoremap <leader>fc :call FoldColumnToggle()<cr>
function! FoldColumnToggle()
if &foldcolumn
setlocal foldcolumn=0
else
setlocal foldcolumn=2
endif
endfunction
" Automatically fold javadoc-style comments in .java, .h and .cpp files.
"autocmd FileType cpp :set fmr=/**,*/ fdm=marker fdc=1
"autocmd FileType h :set fmr=/**,*/ fdm=marker fdc=1
"autocmd FileType java :set fmr=/**,*/ fdm=marker fdc=1
" Automatically fold C-style comments in .java files.
"autocmd FileType java :set fmr=/*,*/ fdm=marker fdc=1
" }}}
" Quickfix window --- {{{
" You have the vim-impaired plugin installed, so you can use
" ]q and [q to navigate the current quickfix list.
" To search all JavaScript files in and below the starting directory,
" :grep pattern **/*.js
" To exclude a directory from being searched,
" :grep --exclude build pattern **/*.js
" When using grep on .js files, ESLint also runs and creates another
" quickfix list. To get back to the one created by grep, run :colder.
" Toggle viewing quickfix list with ,q.
nnoremap <leader>q :call QuickfixToggle()<cr>
let g:quickfixOpen = 0
function! QuickfixToggle()
if g:quickfixOpen
cclose
let g:quickfixOpen = 0
execute g:quickfixReturnToWindow . 'wincmd w'
else
let g:quickfixReturnToWindow = winnr()
copen
let g:quickfixOpen = 1
endif
endfunction
" }}}
" Asynchronous Lint Engine (ALE)
" Limit linters used for JavaScript.
let g:ale_linters = {
\ 'javascript': ['eslint', 'flow'],
\ 'scss': ['stylelint'],
\ 'typescript': ['tslint']
\}
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\}
"let g:ale_fixers.javascript = ['prettier_eslint']
let g:ale_fixers.javascript = ['prettier', 'eslint']
let g:ale_javascript_prettier_options = '--no-bracket-spacing --single-quote'
highlight clear ALEErrorSign " otherwise uses error bg color (typically red)
highlight clear ALEWarningSign " otherwise uses error bg color (typically red)
let g:ale_sign_error = '👎'
let g:ale_sign_warning = '❓'
let g:ale_statusline_format = ['👎 %d', '❓ %d', '']
" %linter% is the name of the linter that provided the message
" %s is the error or warning message
let g:ale_echo_msg_format = '%linter% says %s (%code%)'
" Map keys to navigate between lines with errors and warnings.
" <c-j> works, but <c-k> doesn't because that is mapped to
" clear the screen in iTerm! How can you remove that mapping?
"TODO: Find non-conflicting keys for these!
nnoremap <leader>af :ALEFix<cr>
nnoremap <leader>an :ALENextWrap<cr>
nnoremap <leader>ap :ALEPreviousWrap<cr>
" Asciidoc --- {{{
"autocmd BufRead,BufNewFile *.txt,*.asciidoc,README,TODO,CHANGELOG,NOTES,ABOUT
autocmd BufRead,BufNewFile *.asciidoc,README,TODO,CHANGELOG,NOTES,ABOUT
\ setlocal noautoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2 filetype=asciidoc
\ textwidth=70 wrap formatoptions=tcqn
\ formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\\|^\\s*<\\d\\+>\\s\\+\\\\|^\\s*[a-zA-Z.]\\.\\s\\+\\\\|^\\s*[ivxIVX]\\+\\.\\s\\+
\ comments=s1:/*,ex:*/,://,b:#,:%,:XCOMM,fb:-,fb:*,fb:+,fb:.,fb:>
" }}}
" airline --- {{{
let g:airline#extensions#ale#enabled = 1
" Display list of buffer names at top when only one is visible.
"let g:airline#extensions#tabline#enabled = 1
"let g:airline_powerline_fonts = 1
" Fix colors so status bar is readable in non-active windows.
" See https://github.com/bling/vim-airline/issues/506.
"let g:airline#extensions#branch#enabled = 1 " show git branch
" To hide vim-gutter stats on added, modified, and delete lines ...
"let g:airline#extensions#hunks#enabled=0
"let g:Powerline_symbols = 'fancy'
"set fillchars+=stl:\ ,stlnc:\
"set termencoding=utf-8
"let g:airline_theme_patch_func = 'AirlineThemePatch'
"function! AirlineThemePatch(palette)
"for colors in values(a:palette.inactive)
"let colors[3] = 245
"endfor
"endfunction
" }}}
" Elm --- {{{
let g:elm_jump_to_error = 0
let g:elm_make_output_file = 'elm.js'
let g:elm_make_show_warnings = 0
let g:elm_syntastic_show_warnings = 0
let g:elm_browser_command = ''
let g:elm_detailed_complete = 0
let g:elm_format_autosave = 0
let g:elm_format_fail_silently = 0
let g:elm_setup_keybindings = 1
" }}}
" git --- {{{
let g:gitgutter_max_signs=1200
" }}}
" PostgreSQL --- {{{
nnoremap <leader>po :VipsqlOpenSession launchpad<cr>
nnoremap <leader>pl :VipsqlSendCurrentLine<cr>
nnoremap <leader>pr :VipsqlSendRange<cr>
nnoremap <leader>pb :VipsqlSendBuffer<cr>
nnoremap <leader>pk :VipsqlSendInterrupt<cr>
" }}}
" Pane resize --- {{{
" Resize panes to be equal width when window is resized.
augroup resizeWindow
if has('autocmd')
autocmd!
autocmd VimResized * exe "normal \<c-w>="
endif
augroup end
" }}}
" Rainbow (), [], and {} --- {{{
" This doesn't always work correctly inside JSX code.
" Toggle rainbow plugin.
nnoremap <leader>rp :RainbowParentheses!!<cr>
let g:rainbow#max_level = 16
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]
" }}}
" fixmyjs --- {{{
" This runs "eslint --fix" on current buffer without saving it.
" It requires running "npm install -g fixmyjs eslint eslint-plugin-babel".
let g:fixmyjs_engine = 'eslint'
let g:fixmyjs_rc_path = '~/.eslintrc.json'
noremap <leader>fj :Fixmyjs<cr>
" }}}
" Status line --- {{{
" Always display status line.
set laststatus=2
" Comment out these customizations if using vim-airline
" to control the status line.
set statusline=%t " file name (omits path)
set statusline+=%M " modified flag
set statusline+=%R " read-only flag
"set statusline+=\ %{ALEGetStatusLine()} " Asynchronous Lint Engine
set statusline+=%= " left/right separator
set statusline+=line\ %l " line number
set statusline+=\ of\ %L " total lines
set statusline+=,\ col\ %c, " cursor line number and column
set statusline+=\ %P " percent through file
" Change status line background color based on mode.
highlight StatusLine ctermfg=lightyellow ctermbg=black
autocmd InsertLeave * highlight StatusLine ctermfg=lightyellow ctermbg=black
autocmd InsertEnter * highlight StatusLine ctermfg=darkgreen ctermbg=white
" }}}
" Syntastic --- {{{
" Current this is not being used because ALE is being used instead.
" Stop Syntastic from taking over :E from netrw.
command! E :execute ":Explore"
" Run Syntastic error checking.
nnoremap <leader>sy :SyntasticCheck<cr>
" Don't check HTML files because it considers
" AngularJS directives to be " invalid.
"let g:syntastic_disabled_filetypes=['html']
let g:syntastic_html_checkers=['']
let g:syntastic_javascript_checkers=['eslint']
" }}}
" Tsuquyomi - plugin for TypeScript --- {{{
"autocmd FileType typescript setlocal completeopt+=menu,preview
"autocmd FileType typescript nmap <buffer> <leader>r <plug>(TsuquyomiRenameSymbol)
"autocmd FileType typescript nmap <buffer> <leader>ts : <c-u>echo tsuquyomi#hint()<cr>
" }}}
" UltiSnips plugin {{{
" To select a snippet, move to it with up and down arrow keys.
" To expand a snippet, press ctrl-j.
let g:UltiSnipsExpandTrigger='<c-j>'
let g:UltiSnipsListSnippets='<leader>snips'
" To move between placeholders in a snippet, press ctrl-j and ctrl-k.
let g:UltiSnipsJumpForwardTrigger='<c-j>'
let g:UltiSnipsJumpBackwardTrigger='<c-k>'
nnoremap <leader>es :UltiSnipsEdit<cr>
" This mess of code allows the tab key
" to be used to expand UltiSnips snippets.
"function! g:UltiSnips_Complete()
" call UltiSnips#ExpandSnippet()
" if g:ulti_expand_res == 0
" if pumvisible()
" return "\<C-n>"
" else
" call UltiSnips#JumpForwards()
" if g:ulti_jump_forwards_res == 0
" return "\<TAB>"
" endif
" endif
" endif
" return ""
"endfunction
"function! g:UltiSnips_Reverse()
" call UltiSnips#JumpBackwards()
" if g:ulti_jump_backwards_res == 0
" return "\<C-P>"
" endif
" return ""
"endfunction
"if !exists("g:UltiSnipsJumpForwardTrigger")
" let g:UltiSnipsJumpForwardTrigger = "<tab>"
"endif
"
"if !exists("g:UltiSnipsJumpBackwardTrigger")
" let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
"endif
"au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
"au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=g:UltiSnips_Reverse()<cr>"
" }}}
" vim-flow {{{
" Automatically close the quickfix window that
" is opened when Flow detects a type error
let g:flow#autoclose=1
" Don't automatically perform type checking when a file is saved with :w.
let g:flow#enable=0
" Jump to first line with a type error.
let g:flow#errjmp=1
nnoremap <leader>ft :FlowType<cr>
nnoremap <leader>fj :FlowJumpToDef<cr>
" }}}
" LESS files setup - does this do anything?
autocmd BufNewFile,BufRead *.less set filetype=less
" YouCompleteMe plugin --- {{{
let g:ycm_semantic_triggers = {
\ 'elm' : ['.'],
\}
" Allow use of YCM for all file types.
"let g:ycm_filetype_blacklist = {}
" Use identifiers in Exhuberant Ctags tags files.
" This makes Vim unusable slow and stops any completions from working.
" I get the error (see ycm-users mailing list post).
"let g:ycm_collect_identifiers_from_tags_files = 1
" Toggle g:ycm_auto_trigger option
"nnoremap <leader>y :call YcmToggle()<cr>
"function! YcmToggle()
" if g:ycm_auto_trigger
" let g:ycm_auto_trigger = 0
" else
" let g:ycm_auto_trigger = 1
" endif
"endfunction
" }}}