-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
784 lines (642 loc) · 27.1 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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
" see https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/
set nocompatible " required
" filetype off " required " per vim-plug docs, maybe not required?
" set the runtime path to include Vundle and initialize
" let g:vundle_default_git_proto = 'ssh'
" ^^ instead of that, use git config to replace https with ssh. See
" git-aliases
let s:bundlepath=expand('~/.vim/bundle')
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
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin(s:bundlepath)
" required
Plug 'gmarik/Vundle.vim'
" my plugins
" really good python folds
" but, sadly, slow things down in a 2000+ line file
Plug 'tmhedberg/SimpylFold'
" good python indenting
Plug 'vim-scripts/indentpython.vim'
" inherited from the vimscript from the link at top. I don't actively use this.
" Plugin 'vim-scripts/mru.vim'
" likewise... though now that I read the docs and try the color scheme, I may
" want to try this out!
" Plugin 'jnurmine/Zenburn'
" A jinja plugin. Abandoned because it doesn't handle nested comments properly
Plug 'Glench/Vim-Jinja2-Syntax'
" Plugin for ES6 which Zeconomy uses extensively.
Plug 'isRuslan/vim-es6'
" Git utilities. :Gdiff and :Gblame are very useful.
Plug 'tpope/vim-fugitive'
" I use ack regularly in bash to inspect code; and this is an
" invaluable navigation aid if I actually want to edit around the results.
" Perhaps needless to say you have to have ack to use. Command :Ack.
" Only pitfall, sometimes: https://github.com/mileszs/ack.vim/issues/199
" One of my most-used plugins.
" EDIT: no longer useful. Don't remember why but now i just do
" $ vi -q <(ack ...)
" Plugin 'mileszs/ack.vim'
" Utilities for surrounding braces. Vim comes with a few text object utilities
" along these lines but those just help you specify a selection or a motion;
" this goes further and lets you manipulate the surrounding braces. Frequently
" used: ys{motion}b to surround the contents of motion with parentheses, ds)
" to delete surround parentheses (and keep interior content), cSbb to put
" content on separate line(s) from parens.
" So, so useful.
Plug 'jpassaro/vim-surround'
" Spelling utilities. I mostly use for :Subvert.
Plug 'tpope/vim-abolish'
" in the tpope/* utilities, some complex commands are defined; this basically
" instructs the "." to treat each one as a single command. Very useful.
Plug 'tpope/vim-repeat'
" prereq for many custom text objects that I find invaluable. I don't really
" use it directly.
Plug 'kana/vim-textobj-user'
" indent-based text objects. ai for everything at this indent level or above;
" ii restricts further to the current paragraph. super useful.
Plug 'kana/vim-textobj-indent'
" al means whole line; il means line minus surrounding whitespace.
" Occasionally useful.
Plug 'kana/vim-textobj-line'
" text objects based on arguments to a function. ia is the current argument,
" aa is that plus whitespace and one comma if present. Do not use outside
" braces. However it seems to play reasonably nicely with {} and [].
" Very important.
Plug 'b4winckler/vim-angry'
" name explains itself. example: *C*amelCaseMotion, after \w, navigates to
" Camel*C*aseMotion. Works with snake_case as well. Provides text objects for
" inner words as well. So, so useful.
Plug 'bkad/CamelCaseMotion'
" Lets you run flake8 on your script. Works well and very useful; not sure why
" I'm so unexcited to document it.
Plug 'nvie/vim-flake8'
" Useful largely for highlighting csv file. Has many commands beginning with
" CSV, found them well-documented the few times I've needed them.
Plug 'chrisbra/csv.vim'
" A bunch of ]-mappings. [q / ]q move you through quickfix list, [f / ]f move
" through arg files, &c. [e / ]e moves current line or selection up or down by
" [count] lines; [<space> / ]<space> adds lines above or before this line
" instead of calling o<Esc> or O<Esc>. Saves a lot of time.
Plug 'tpope/vim-unimpaired'
" runs make and shit asynchronously. ack.vim has this as an optional
" dependency; it improves performance very noticeably and seems to solve an
" extremely annoying problem I was running into occasionally
" (https://github.com/mileszs/ack.vim/issues/199). Highly recommend, at least
" with ack.vim.
Plug 'tpope/vim-dispatch'
" adds endif, done, etc in bash and vimL, one day jinja.
Plug 'tpope/vim-endwise'
" autocomplete; untested
" been having performance problems, don't know if this is why but can't hurt
" Plugin 'davidhalter/jedi-vim'
" instead we try this which seems to be more popular. Requires MacVim.
" holy shit, real performance issues... maybe my computer sucks
" Plugin 'Valloric/YouCompleteMe'
" syntastic is working pretty well... mostly replaces vim-flake8 too!
Plug 'vim-syntastic/syntastic'
" compiler settings for eslint
Plug 'salomvary/vim-eslint-compiler'
" workflow helper, for SQL especially
Plug 'krisajenkins/vim-pipe'
" syntax highlighter for postgres-specific SQL
"Plugin 'krisajenkins/vim-postgresql-syntax'
" recommended by SimpylFold to speed up folding (it's pretty bad for large
" files...
Plug 'Konfekt/FastFold'
" graphviz -- digraphs
Plug 'wannesm/wmgraphviz.vim'
" read coverage report
" problems with nvim; disposable
"Plug 'mgedmin/coverage-highlight.vim'
" mscgen syntax
Plug 'goodell/vim-mscgen'
" possible improvement on previous jinja plugin. Abandoned in favor of custom
" fix in .vim/after/syntax/jinja.vim
" Plugin 'mitsuhiko/vim-jinja'
" support for direnv files and settings
" Plugin 'direnv/direnv.vim'
" new and improved python syntax
Plug 'vim-python/python-syntax'
" more tpope: xml autofill
Plug 'tpope/vim-ragtag'
" maybe puts git line status in the 'gutter'?
Plug 'airblade/vim-gitgutter'
" adds useful stuff like :Chmod
Plug 'tpope/vim-eunuch'
" cross-editor text properties
" Plug 'editorconfig/editorconfig-vim'
" better statusline plugin
Plug 'itchyny/lightline.vim'
" typescript
Plug 'leafgarland/typescript-vim'
" date increments (primarily for .progress/log)
Plug 'tpope/vim-speeddating'
" pug templates for node development
Plug 'digitaltoad/vim-pug'
if has('nvim')
Plug 'nvim-lua/plenary.nvim'
Plug 'scalameta/nvim-metals'
Plug 'ishan9299/nvim-solarized-lua'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'mfussenegger/nvim-dap'
Plug 'mfussenegger/nvim-dap-python'
else
" coc for scala
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'scalameta/coc-metals', {'do': 'npm install --frozen-lockfile'}
" new shiny color scheme
Plug 'altercation/vim-colors-solarized'
endif
Plug 'vim-test/vim-test'
Plug 'hashivim/vim-terraform'
Plug 'mogelbrod/vim-jsonpath'
" All Plugins must be added before the following line
call plug#end() " required
" filetype plugin indent on " required " per vim-plug docs, maybe not required?
" function CheckVundle(featurename)
" let result = exists('s:vundlepath')
" if ! ( result || empty(a:featurename) )
" echoerr 'need vundle installed to support' a:featurename
" endif
" return result
" endfunction
" \w, \b, \e, a\w, i\w ... etc, motions for moving inside a camel case word.
"if CheckVundle('camel case mappings')
silent! call camelcasemotion#CreateMotionMappings('<leader>')
"endif
" syntax highlighting! I think.
" syntax on " per vim-plug docs, maybe not required?
"define BadWhitespace before using in a match
highlight BadWhitespace ctermbg=red guibg=darkred
autocmd ColorScheme * highlight BadWhitespace ctermbg=red guibg=darkred
autocmd BufRead,BufNewFile * match BadWhitespace /\s\+$/
" shortcut for unfolding a fold.
" nnoremap <space> za
" Disabled in favor of using z-* keybindings directly, which are somewhat more
" powerful and more useful.
" number lines, always, no exceptions
set number
" backspace works globally
set backspace=start,indent,eol
" keeps buffers around if you "abandon" them. I don't entirely understand it.
set hidden
" display this funny unicode thing for every tab everywhere, with width 8
set list listchars=tab:⟩— tabstop=8
" use spaces instead when entering new content, and let my tabs have width 4.
" shiftwidth too, see docs for distinction.
set expandtab softtabstop=4 shiftwidth=4
" formerly the tabstop bits were in a filetype autocmd; now we set them
" globally.
" autocmd Filetype javascript,html,jinja,vim,python,gitcommit setlocal ...
" special babies in which for some reason 2-char indent works better
autocmd Filetype sh,scala,yaml setlocal softtabstop=2 shiftwidth=2
" I do not remember how this got in here. It seems fine.
au BufEnter /private/tmp/crontab.* setlocal backupcopy=yes
set hlsearch " highlights a completed search
set incsearch " jumps to and highlights a search as you type
" use \n to temporarily suppress search highlighting
nnoremap <Leader>n :<C-U>noh<CR>:<CR>
set laststatus=2
"if CheckVundle('fancy status line')
let s:lspstatus = has('nvim') ? 'nvi-lsp' : 'cocstatus'
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'inactive': {
\ 'left': [
\ ['filename', 'modified', 'filetype', 'fileformat'],
\ ['branchname', 'timestamp']
\ ],
\ 'right': [
\ ['jpdimensions'],
\ ['lineinfo', 'percent'],
\ ]
\ },
\ 'active': {
\ 'left': [
\ ['mode'],
\ ['readonly', 'filename', 'modified', 'filetype', 'fileformat'],
\ ['branchname', 'timestamp', s:lspstatus]
\ ],
\ 'right': [
\ ['jpdimensions'],
\ ['charvaluehex', 'byteinfo'],
\ ['lineinfo', 'percent'],
\ ]
\ },
\ 'component': {
\ 'charvaluehex': '0x%B',
\ 'jpdimensions': '(%{winwidth(0)}x%{winheight(0)})',
\ 'percent': '%P',
\ 'fileformat': '%{&ff==#"unix"?"":&ff}',
\ 'nvi-lsp': '%{exists("g:metals_status") ? g:metals_status : ""}',
\ 'lineinfo': '%l:%c/L=%L',
\ 'filetype': 'ft=%{&ft}'
\ },
\ 'component_visible_condition': {
\ 'fileformat': '&ff==#"unix" || &ff',
\ 'filetype': '&ft',
\ 'nvi-lsp': 'exists("g:metals_status") && g:metals_status != ""'
\ },
\ 'component_function': {
\ 'timestamp': 'JPtimestamp',
\ 'cocstatus': 'coc#status',
\ 'byteinfo': 'JPByteInfo',
\ 'branchname': 'JPshortGitHead'
\ }
\}
let g:jp_byte_info_measure = 'bytes'
let g:jp_byte_info_hex = 0
function Togglebyteinfohex()
if g:jp_byte_info_hex
let g:jp_byte_info_hex = 0
else
let g:jp_byte_info_hex = 1
endif
endfunction
nmap <leader>x :call Togglebyteinfohex()<CR>
function JPByteInfo()
let l:wc = wordcount()
let l:fmt = g:jp_byte_info_hex ? '%X' : '%d'
let l:msr = g:jp_byte_info_measure
let l:vis = 'visual_' . l:msr
if has_key(l:wc, l:vis)
return printf(printf('%s %%s selected', l:fmt), l:wc[l:vis], l:msr)
else
let l:bytes = l:wc[l:msr]
let l:cbytes = l:wc['cursor_' . l:msr]
return printf(printf('b=%s/%s', l:fmt, l:fmt), l:cbytes, l:bytes)
endif
endfunction
function JPtimestamp()
return strftime('%e %b %T')
endfunction
if ! exists('g:jpmaxgitbrlen')
let g:jpmaxgitbrlen = 12
endif
function JPshortGitHead()
return fugitive#Head()[0 : g:jpmaxgitbrlen]
endfunction
" else
" " set a useful statusline
" set ruler
"
" " timestamp in ruler pulled from vim wikia
" " window dimensions in ruler entirely my own (-: it took some doing!
" set rulerformat=%47(%{strftime('%b\ %T\ %p')}\ %5l,%-6(%c%V%)\ %P%10((%{winwidth(0)}x%{winheight(0)})%)%)
" endif
" mark the right border with a subtle grey. That's 80 in python/vimL, 72 in
" commit messages, for now the biggest places I care about line length.
autocmd Filetype python,gitcommit,vim,bash,pullrequest highlight ColorColumn ctermbg=235
" soft limit, no real need to enforce.
autocmd Filetype python,vim,bash,markdown,rst,text setlocal colorcolumn=+2 textwidth=78
autocmd FileType pullrequest setlocal textwidth=72
" no autowrap on text
autocmd Filetype python setlocal formatoptions-=t
" continue comment on <Enter> in Insert mode
autocmd Filetype python,bash setlocal formatoptions+=r
" strict limit; textwidth=72 from distro plugin, and it also sets
" formatoptions to my liking
autocmd Filetype gitcommit,pullrequest setlocal colorcolumn=+0 " textwidth is already 72
" don't autocomment in vimscripts. however, leave 'c' so that it can autowrap
" a very long comment like this one
autocmd Filetype vim setlocal fo-=ro
" create custom vim-surround setting for {% %} and {# #} blocks in jinja
" got the first one from SO i think, link now lost. The others are all me.
autocmd Filetype jinja
\ let b:surround_{char2nr('^')} = "{% \1{% \1 %}\r{% end\1\r .*\r\1 %}"
autocmd Filetype jinja
\ let b:surround_{char2nr('%')} = "{% \r %}"
autocmd Filetype jinja
\ let b:surround_{char2nr('#')} = "{# \r #}"
" enact syntax folds to fight the incredible verbosity of zeconomy email
" templates. see vim-dir/after/syntax/html.vim for custom htmlFold definition.
" The built-in folds are pretty nice too (-:
autocmd BufRead,BufNewFile app/templates/email/*.html
\ setlocal foldmethod=syntax
" for debugging syntax settings, copied from vim wikia
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
" sets :make to run f8diff and read errors into a quickfix list.
" errorformat copied from nvie/vim-flake8
command SetPyMake setlocal makeprg=flake8 makeef=/tmp/flake.err errorformat="%f:%l:%c: %m\,%f:%l: %m"
autocmd Filetype python SetPyMake
" my convention is to save temporary git files as "./.log"
autocmd BufRead,BufNewFile .log setf gitcommit
" define command :Nocommit to abandon a git commit message but save the results
autocmd Filetype gitcommit command Nocommit call GitNoCommit()
function GitNoCommit()
if expand('%') == ".log"
" ... that's where we would be saving the file. Ya goofed.
echo "you're working on .log right now you lumbering halfwit."
return
endif
write! .log
%delete
write
quit
endfunction
" helpful wildcard settings
set wildmode=full wildmenu
" displays full list of wildcard matches as you tab through them
" set splitright
" search code base for whole-word matches of current word. Kind of like "*"
" across a whole project instead of a file.
nnoremap gb :Ack -Qw <cword><CR>
" same but cWORD indicates non-space "word" instead of token-defined "word"
nnoremap gB :Ack -Qw <cWORD><CR>
autocmd BufRead,BufNewFile Dockerfile.* setlocal filetype=dockerfile
" vizualizes fold structure
autocmd FileType python set foldcolumn=4
" function DeleteBackward(count, newline) abort
" exec "normal! ". a:count . "X"
" if a:newline
" normal! i<CR><Esc>
" repeat#set("\<Plug>JpassaroDeleteBackwardNewline", count)
" else
" repeat#set("\<Plug>JpassaroDeleteBackward", count)
" endif
" endfunction
" nnoremap <silent> <Plug>JPassaroDeleteBackward :<C-U>call DeleteBackward(v:count1)
" delete backward then start an insert.
" TODO: try and figure out how to use repeat.vim on this.
nnoremap <unique> S Xi
nnoremap <unique> zS Xi<CR><Esc>
" A bunch of stuff to populate the search register and highlight the results.
" Inspired by something on the msgboard that points out you don't always want
" the usual "*" behavior of navigating to the next match in order to get the
" highlighting.
" highlight matches of the current word
nmap <silent> z* <Plug>JpvimrcNohi:call SetSearch(expand("<cword>"))<CR>:let v:searchforward = 1<CR>
" highlight matches of the current word when they appear as a word
nmap <silent> Z* <Plug>JpvimrcNohi:call SetSearch("<".expand("<cword>").">")<CR>:let v:searchforward = 1<CR>
" like the above but with cWORD instead of cword (i.e. iW instead of iw)
nmap <silent> <Leader>z* <Plug>JpvimrcNohi:call SetSearch(expand("<cWORD>"))<CR>:let v:searchforward = 1<CR>
nmap <silent> <Leader>Z* <Plug>JpvimrcNohi:call SetSearch("<".expand("<cWORD>").">")<CR>:let v:searchforward = 1<CR>
" like the above but set search direction to backward
nmap <silent> z# <Plug>JpvimrcNohi:call SetSearch(expand("<cword>"))<CR>:let v:searchforward = 0<CR>
nmap <silent> Z# <Plug>JpvimrcNohi:call SetSearch('\<'.expand("<cword>").'\>')<CR>:let v:searchforward = 0<CR>
nmap <silent> <Leader>z# <Plug>JpvimrcNohi:call SetSearch(expand("<cWORD>"))<CR>:let v:searchforward = 0<CR>
nmap <silent> <Leader>Z# <Plug>JpvimrcNohi:call SetSearch("<".expand("<cWORD>").">")<CR>:let v:searchforward = 0<CR>
" search for next/last use of cWORD
nmap <silent> <Leader>* <Leader>z*n
nmap <silent> <Leader># <Leader>z#n
" search for next/last instance of selection. Normally keeps you in visual and
" just moves cursor to next word, which is sensible but rarely useful for me.
vmap <silent> z* <Plug>JpvimrcNohi:call SetSearchFromSelection(visualmode())<CR>:let v:searchforward = 1<CR>
vmap <silent> z# <Plug>JpvimrcNohi:call SetSearchFromSelection(visualmode())<CR>:let v:searchforward = 0<CR>
" like the above mappings but navigate as well.
vmap <silent> * z*n
vmap <silent> # z#n
" place text under motions into search register and highlight them. only works
" with character-wise motions.
nmap <silent> =* <Plug>JpvimrcNohi:<C-U>set operatorfunc=SetSearchFromSelection<CR>g@
nmap <silent> g=* <Plug>JpvimrcNohi:<C-U>set operatorfunc=SetSearchFromSelectionCaseInsensitive<CR>g@
" this doesn't work because i can't call let v:searchforward afterward
"nmap <silent> =# <Plug>JpvimrcNohi:<C-U>set operatorfunc=SetSearchBackward<CR>g@
nmap <silent> =# :echoerr '(jpvimrc) searching backward from a motion is not supported'<CR>
" this is undone at the end of a function, so it has to be done directly in
" the mapping. Likewise the :let v:searchforward = ?
map <silent> <Plug>JpvimrcNohi :<C-U>set nohlsearch<CR>
" set the search pattern and direction and activate hlsearch
function SetSearch(patt)
let thing = a:patt
let @/ = thing
set hlsearch
endfunction
" to use with motion operators and visual mode
" doesn't work with linewise selection/motions or block selection
function s:setSearchFromSelection(type)
let sel_save = &selection
let reg_save = @@
try
if a:type == 'v' " visualmode() in char mode
silent exe "normal! gvy"
elseif a:type == 'char' " from g@ for character motions
silent exe "normal! `[v`]y"
else
throw '(jpvimrc) cannot set search pattern from a non-char selection'
endif
call SetSearch('\V' . @@)
finally
let &selection = sel_save
let @@ = reg_save
endtry
endfunction
function SetSearchFromSelection(type) abort
try
call s:setSearchFromSelection(a:type)
catch /^(jpvimrc)/
echoerr v:exception
endtry
endfunction
" tried zenburn... it was okay but not always.
" I'm currently liking slate for html...
if $ITERM_PROFILE =~? 'solarized' " && CheckVundle('solarized')
colorscheme solarized
else
colorscheme slate
endif
function! NewlineNearCursor(where) abort
let nlcount = v:count1
let origcol = col('.')
let leftcol = col('.')
let curline = getline('.')
if a:where == 'before'
let action = 'i'
while leftcol >= 2 && curline[leftcol-2] =~ '\s'
let leftcol -= 1
endwhile
let repeatable = "\<Plug>JpvimrcNewlineBeforeCursor"
elseif a:where == 'after'
let action = 'a'
let leftcol += 1
let repeatable = "\<Plug>JpvimrcNewlineAfterCursor"
else
throw '(jpvimrc) bad argument "' . a:where . '"'
endif
let rightcol = max([origcol, leftcol])
while rightcol <= len(curline) && curline[rightcol-1] =~ '\s'
let rightcol += 1
endwhile
if rightcol > leftcol
call cursor('.', leftcol)
execute 'normal! "_' . (rightcol - leftcol) . 'x'
let action = 'i'
endif
execute "normal! " nlcount . action . "\<CR>"
silent! call repeat#set(repeatable, nlcount)
endfunction
nnoremap <unique> <Plug>JpvimrcNewlineBeforeCursor :<C-U>call NewlineNearCursor("before")<CR>
nnoremap <unique> <Plug>JpvimrcNewlineAfterCursor :<C-U>call NewlineNearCursor("after")<CR>
" Another unimpaired-style mapping to create newlines.
nmap <unique> [<CR> <Plug>JpvimrcNewlineBeforeCursor
nmap <unique> ]<CR> <Plug>JpvimrcNewlineAfterCursor
" tell ack.vim to use dispatch
let g:ack_use_dispatch = 1
let g:dispatch_use_shell_escape = 1
" syntastic settings
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_python_checkers = ['flake8', 'mypy']
" let g:syntastic_python_flake8_args = '--select=E901,F821,F401,F841,F812'
let g:syntastic_sh_shellcheck_args = '-x'
function OverridePermissiveFlake8()
let lastline = getline('$')
if lastline =~? '^\s*\#.*autoflake'
let b:syntastic_python_flake8_args = ''
elseif lastline =~? '^\s*#.*dirtyflake'
let b:syntastic_python_flake8_args = '--select=E901'
endif
endfunction
autocmd FileType python call OverridePermissiveFlake8()
autocmd FileType javascript compiler eslint
autocmd BufRead,BufNewFile *.har set filetype=json
function! LoanCalc() abort
normal! G
read !python ~/.vim/loan-calc.py %
endfunction
autocmd FileType json command! LoanCalc :call LoanCalc()<CR>
let g:SimpylFold_fold_import = 0
let g:WMGraphviz_output = 'png'
autocmd filetype dot call SetupVimPipe("dot-pipe -o")
" unimpaired: ]<C-Q> doesn't work for unknown reasons, providing an alternative
nmap [Z <Plug>unimpairedQPFile
nmap ]Z <Plug>unimpairedQNFile
" used with builtin python indenter, see :help ft-pythong-indent
" let g:pyindent_open_paren = '&sw'
" let g:pyindent_continue = '&sw'
" suggested by vim_use mailing list
set t_u7=
set t_RV=
if $TERM_PROGRAM =~? 'iterm'
let &t_SI = "\<ESC>]1337;CursorShape=1\x7" " vertical bar
let &t_SR = "\<ESC>]1337;CursorShape=2\x7" " underline
let &t_EI = "\<ESC>]1337;CursorShape=0\x7" " block
endif
" for vim-python/python-syntax
let g:python_highlight_all = 1
let g:python_highlight_string_templates = 0
" enable vim-pipe on selections
function SetupVimPipe(cmd)
let b:vimpipe_command=a:cmd
vnoremap <silent><buffer> <LocalLeader>r :<C-U>'<,'> call VimPipe()<CR>
nnoremap <silent><buffer> <LocalLeader>r :<C-U>. call VimPipe()<CR>
let g:vimpipe_invoke_map = '<LocalLeader>R'
endfunction
" suppress mapping <LocalLeader>r
let g:vimpipe_invoke_map = '<Plug>JPVimrc_invoke_vimpipe'
" vim-pipe mysql
function SetupMysqlVimpipe(db, host, user, password)
let b:vimpipe_command = "mysql " . a:db
\ . " --host=" . a:host
\ . " --user=" . a:user
\ . " --password='" . a:password
\ . "' --table"
endfunction
" i am getting so tired of syntax errors when sh files use bash
" constructions...
let g:bash_is_sh = 1
" make sure there is time to finish syntax highlighting
set redrawtime=4000 " usually 2000
" how long gitgutter has to wait before updating lines
set updatetime=250
autocmd BufEnter */mothersback/ts/*.ts let b:syntastic_checkers = ["tsc", "tslint"]
autocmd BufRead,BufNewFile *.njk set filetype=jinja
autocmd BufRead,BufNewFile */.progress/log.txt call SetUpProgressLog()
autocmd BufRead,BufNewFile ~/_progress/log.txt call SetUpProgressLog()
function SetUpProgressLog()
if exists('b:jp_progress_log_setup')
return
endif
let b:jp_progress_log_setup = 1
autocmd BufWritePost <buffer> call SaveProgressCopy()
"map <buffer> <Leader>r :<C-U>call ResetProgressLog()<CR>
command -buffer ProgressNext call ResetProgressLog()
endfunction
function ProgressLogDate()
if ! search('^\vDate: \zs\d{4}-\d{2}-\d{2}%(.*/)@!', 'cw')
throw '(jpvimrc) Unable to find a "Date:" line (does it have slash?)'
endif
endfunction
function SaveProgressCopy()
let oldlnum = line('.')
let oldcnum = col('.')
try
call ProgressLogDate()
let backup = expand('%') . '.vimbak.' . expand('<cfile>')
exec "write!" backup
finally
call cursor(oldlnum, oldcnum)
endtry
endfunction
if ! exists('g:jpvimrc_progress_todaygoal')
let g:jpvimrc_progress_todaygoal = '@goalsfortoday'
endif
if ! exists('g:jpvimrc_progress_todayactual')
let g:jpvimrc_progress_todayactual = '@actualaccomplishment'
endif
if ! exists('g:jpvimrc_progress_tmrwgoal')
let g:jpvimrc_progress_tmrwgoal = '@nextdaygoals'
endif
function SearchForwardOrBust(patt)
if ! search('.\+' . a:patt . '$')
throw '(jpvimrc) did not find "' . a:patt . '" ahead of current cursor'
endif
return line('.')
endfunction
function ResetProgressLog() abort
let todaygoal = g:jpvimrc_progress_todaygoal
let todayactual = g:jpvimrc_progress_todayactual
let tmrwgoal = g:jpvimrc_progress_tmrwgoal
silent write
call ProgressLogDate()
exec "normal!" "C" . strftime("%Y-%m-%d")
let toinsert = ['']
let deletestart = 1 + SearchForwardOrBust(todaygoal)
call extend(toinsert, [getline(SearchForwardOrBust(todayactual)), '', ''])
let deleteend = SearchForwardOrBust(tmrwgoal)
call extend(toinsert, [getline('.'), '', ''])
call deletebufline('%', deletestart, deleteend)
call search('{END LOG}', 'cw')
call append(line('.') - 1, toinsert)
call search(g:jpvimrc_progress_todayactual . '$', 'b')
call cursor(1 + line('.'), 0) " equiv: normal j0
endfunction
autocmd FileType jinja call RagtagInit()
hi Define ctermfg=10
nnoremap <unique> <Leader>c :<C-U>helpclose<CR>
if !has('nvim')
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nmap <silent> <c-k> :call CocAction('doHover')<CR>
inoremap <silent><expr> <C-A> coc#refresh()
nmap <LocalLeader>rn <Plug>(coc-rename)
endif
" tmux intercepts ^b; create an alternative
cnoremap <C-A> <C-B>
" white-out
function! WhiteOut() abort
let thecount = v:count1
let oldreg = getreg('a')
let oldregtype = getregtype('a')
try
call setreg('a', 'r l')
exec 'normal! ' . thecount . '@a'
finally
call setreg('a', oldreg, oldregtype)
silent! call repeat#set("\<Plug>JpvimrcWhiteOut", nlcount)
endtry
endfunction
nnoremap <Plug>JpvimrcWhiteOut :<C-U>silent! call WhiteOut()<CR>
nmap <unique> <silent> <Leader><space> <Plug>JpvimrcWhiteOut
let g:EditorConfig_verbose = 1