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
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
|
"LEMON'S VIMRC - 16 NOVEMBER 2014
" Preamble {{{...
set t_Co=256
set background=dark
set path+=**
"}}}
"
" set syntax on
syntax on
" vertical diff please
set diffopt=vertical
" twdft colouring and syntaxing
autocmd BufNewFile,BufRead *.twdft set syntax=markdown
" macro to create and delete a 'check a box'
"nmap 1 0f[lrx
nmap 1 0f rx
nmap 2 0fxr
"
" Remap the leader key {{{...
let mapleader = ","
"...}}}
"
" map ESCAPE to exit to Normal mode in neovim terminal {{{...
tnoremap <Esc> <C-\><C-N>
" ...}}}
"
" Signify mapping & config
nnoremap <leader>R :SignifyRefresh<CR>
let g:signify_realtime = 1
"
" Basic options {{{...
set cmdheight=1
set termguicolors
set inccommand=split
set foldmethod=manual
set encoding=utf-8
set modelines=0
set relativenumber
set autoindent
set showmode
set cursorline
set ttyfast
set ttimeout
set notimeout
set nottimeout
set backspace=indent,eol,start
set ruler
set laststatus=2
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set number
set fillchars=diff:⣿,vert:\|
set noswapfile
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set vb
"set list
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set lazyredraw
set matchtime=3
set showbreak=↪
set shell=/usr/local/bin/fish
set splitbelow
set splitright
set autowrite
set autoread
set linebreak
set hidden
"set colorcolumn=80
"...}}}
" Wildmenu completion {{{
set wildmenu
" set wildmode=list:longest " don't like this
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
" Clojure/Leiningen
set wildignore+=classes
set wildignore+=lib
" }}}
" Make Vim able to edit crontab files ... {{{
set backupskip=/tmp/*,/private/tmp/*"
"...}}}
" Remaps ...{{{
"NERDTree!
nmap \e :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
" targbar handler
nmap <F8> :TagbarToggle<CR>
" Don't use Ex mode, use Q for formatting
"map Q gq
" easier formatting of paragraphs
" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc
vmap Q gq
nmap Q gqap
" set trailing whitespace to be visible with using special chars with ,s
"set listchars=tab:>-,trail:*,eol:$
"nmap <silent> <leader>s :set nolist!<CR>
" some misc settings
:nmap \l :setlocal number!<CR>
:nmap \o :set paste!<CR>
" map sort function to a key
" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc
vnoremap <Leader>s :sort<CR>
" Plug Plugs...{{{
call plug#begin('~/.config/nvim/plugged')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'lervag/vimtex' " does not work with Latex Box in vim-polyglot
Plug 'google/yapf', { 'rtp': 'plugins/vim', 'for': 'python' }
Plug 'hdima/python-syntax'
Plug 'deoplete-plugins/deoplete-go', {'do': 'make'}
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'rust-lang/rust.vim'
Plug 'reewr/vim-monokai-phoenix'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'zchee/deoplete-jedi'
Plug 'mhinz/vim-signify' " marking changes in repo
Plug 'anekos/hledger-vim'
Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries'}
Plug 'buoto/gotests-vim'
Plug 'bitc/vim-hdevtools'
Plug 'NLKNguyen/papercolor-theme'
Plug 'neovimhaskell/haskell-vim'
Plug 'ledger/vim-ledger'
Plug 'sophacles/vim-bundle-mako'
"Plug 'zchee/deoplete-clang'
Plug 'chriskempson/vim-tomorrow-theme'
Plug 'sbdchd/neoformat'
Plug 'w0rp/ale'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
"Plug 'rking/ag.vim'
Plug 'tmhedberg/SimpylFold'
Plug 'tpope/vim-surround'
Plug 'plasticboy/vim-markdown'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'dag/vim-fish'
Plug 'majutsushi/tagbar'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'jlanzarotta/bufexplorer'
Plug 'jmcantrell/vim-virtualenv'
Plug 'sukima/xmledit'
Plug 'mileszs/ack.vim'
Plug 'klen/python-mode'
Plug 'Shougo/neosnippet'
Plug 'Shougo/neosnippet-snippets'
Plug 'itchyny/lightline.vim'
Plug 'mhinz/vim-grepper'
Plug 'sickill/vim-pasta'
Plug 'sheerun/vim-polyglot'
Plug 'tommcdo/vim-fubitive'
Plug 'janko-m/vim-test'
Plug 'tpope/vim-dispatch'
Plug 'radenling/vim-dispatch-neovim'
Plug 'sunaku/vim-dasht'
Plug 'Shougo/neoinclude.vim'
Plug 'sebdah/vim-delve'
Plug 'ambv/black'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'bitc/vim-hdevtools'
Plug 'tweekmonster/django-plus.vim'
Plug 'morhetz/gruvbox'
Plug 'junegunn/limelight.vim'
Plug 'nathangrigg/vim-beancount'
Plug 'junegunn/vim-peekaboo'
Plug 'cormacrelf/vim-colors-github'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
call plug#end()
" point neovim to virtualenv specific to neovim (using 3.7)
let g:python3_host_prog = "/home/lemon/.virtualenvs/neovim3.7/bin/python3"
"..{{{ rainbow_parentheses
"activation based on file type
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme,python RainbowParentheses
augroup END
"..}}}
""..{{{ lightline and coc
"
"function! StatusDiagnostic() abort
" let info = get(b:, 'coc_diagnostic_info', {})
" if empty(info) | return '' | endif
" let msgs = []
" if get(info, 'error', 0)
" call add(msgs, 'E' . info['error'])
" endif
" if get(info, 'warning', 0)
" call add(msgs, 'W' . info['warning'])
" endif
" return join(msgs, ' ') . ' ' . get(g:, 'coc_status', '')
"endfunction
"
"let g:lightline = {
" \ 'colorscheme': 'monokai-phoenix',
" \ 'active': {
" \ 'left': [ [ 'mode', 'paste' ],
" \ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
" \},
" \ 'component_function': {
" \ 'cocstatus': 'StatusDiagnostic'
" \ },
" \}
"autocmd User CocStatusChange,CocDiagnosticsChange call lightline#update()
""..}}}
"
"" ..{{{ coc.vim
"let g:coc_node_path = "/usr/bin/nodejs"
"" ..}}}
"
"" Some servers have issues with backup files, see #649
"set nobackup
"set nowritebackup
"
"" Better display for messages
"set cmdheight=2
"
"" You will have bad experience for diagnostic messages when it's default 4000.
"set updatetime=300
"
"" don't give |ins-completion-menu| messages.
"set shortmess+=c
"
"" always show signcolumns
"set signcolumn=yes
"
"" Use tab for trigger completion with characters ahead and navigate.
"" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
"inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
"
"function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
"endfunction
"
"" Use <c-space> to trigger completion.
"inoremap <silent><expr> <c-space> coc#refresh()
"
"" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
"" Coc only does snippet and additional edit on confirm.
"inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"
"" Use `[c` and `]c` to navigate diagnostics
"nmap <silent> [c <Plug>(coc-diagnostic-prev)
"nmap <silent> ]c <Plug>(coc-diagnostic-next)
"
"" Remap keys for gotos
"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)
"
"" Use K to show documentation in preview window
"nnoremap <silent> K :call <SID>show_documentation()<CR>
"
"function! s:show_documentation()
" if (index(['vim','help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" else
" call CocAction('doHover')
" endif
"endfunction
"
"" Highlight symbol under cursor on CursorHold
"autocmd CursorHold * silent call CocActionAsync('highlight')
"
"" Remap for rename current word
"nmap <leader>rn <Plug>(coc-rename)
"
"" Remap for format selected region
"xmap <leader>f <Plug>(coc-format-selected)
"nmap <leader>f <Plug>(coc-format-selected)
"
"augroup mygroup
" autocmd!
" " Setup formatexpr specified filetype(s).
" autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" " Update signature help on jump placeholder
" autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
"augroup end
"
"" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
"xmap <leader>a <Plug>(coc-codeaction-selected)
"nmap <leader>a <Plug>(coc-codeaction-selected)
"
"" Remap for do codeAction of current line
"nmap <leader>ac <Plug>(coc-codeaction)
"" Fix autofix problem of current line
"nmap <leader>qf <Plug>(coc-fix-current)
"
"" Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
"nmap <silent> <TAB> <Plug>(coc-range-select)
"xmap <silent> <TAB> <Plug>(coc-range-select)
"xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
"
"" Use `:Format` to format current buffer
"command! -nargs=0 Format :call CocAction('format')
"
"" Use `:Fold` to fold current buffer
"command! -nargs=? Fold :call CocAction('fold', <f-args>)
"
"" use `:OR` for organize import of current buffer
"command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
"
"
"" Add status line support, for integration with other plugin, checkout `:h coc-status`
""set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
"
"" Using CocList
"" Show all diagnostics
"nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
"" Manage extensions
"nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
"" Show commands
"nnoremap <silent> <space>c :<C-u>CocList commands<cr>
"" Find symbol of current document
"nnoremap <silent> <space>o :<C-u>CocList outline<cr>
"" Search workspace symbols
"nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
"" Do default action for next item.
"nnoremap <silent> <space>j :<C-u>CocNext<CR>
"" Do default action for previous item.
"nnoremap <silent> <space>k :<C-u>CocPrev<CR>
"" Resume latest coc list
"nnoremap <silent> <space>p :<C-u>CocListResume<CR>
"
"
"
" ..{{{ LanguageClient config (base from github
"
" Required for operations modifying multiple buffers like rename.
"set hidden
"let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls' '-vv', '--log-file', '~/pyls.log'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" Instuctions for clangd here: https://clang.llvm.org/extra/clangd/Installation.html
"let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'cpp': ['clangd'],
" \ 'c': ['clangd'],
" \ }
"let g:LanguageClient_settingsPath = 'ls-settings.json'
" NOT REQUIRED WITH COC
"let g:LanguageClient_useVirtualText = 1
"let g:LanguageClient_diagnosticsEnable = 0
"let g:LanguageClient_settingsPath=expand('~/.local/share/nvim/settings.json')
"
"nnoremap <F5> :call LanguageClient_contextMenu()<CR>
"" Or map each action separately
"nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
"nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
"nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"nnoremap <silent> <F3> :call LanguageClient#textDocument_typeDefinition()<CR>
"nnoremap <silent> <F4> :call LanguageClient#textDocument_documentSymbol()<CR>
"nnoremap <silent> <F6> :call LanguageClient#textDocument_references()<CR>
"nnoremap <silent> <F7> :call LanguageClient#workspace_symbol()<CR>
"autocmd FileType * call LC_maps()
" ..}}}
" ..{{{ Rust
let g:autofmt_autosave = 1
" ...}}}
" ..{{{ gruvbox config
let g:gruvbox_contrast_dark = "hard"
let g:gruvbox_invert_signs = 1
let g:gruvbox_italic = 1
let g:gruvbox_invert_indent_guides = 1
"let g:gruvbox_italicize_strings = 1
" ...}}}
" vim-hdevtools for Haskell ..{{
au FileType haskell nnoremap <buffer> <F1> :HdevtoolsType<CR>
au FileType haskell nnoremap <buffer> <silent> <F2> :HdevtoolsClear<CR>
" }}
" vim-test config ..{{{
" use vim-dispatch to run tests in the quickfix window
" from Modern Vim Ch.4
" the mappings below are from vim-test
" https://github.com/janko/vim-test
" dispatch opens send test output to quickfix window
"let test#strategy = "dispatch"
" neovim strategy runs the test in the neovim terminal
let test#strategy = "neovim"
let test#neovim#term_position = "topleft"
let test#python#pytest#options = '-vvv --tb=short'
" To run mypy using vim-dispath -with Dispatch
autocmd FileType python let b:dispatch = 'mypy --ignore-missing-imports'
nmap <silent> t<C-n> :TestNearest<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-s> :TestSuite<CR>
"nmap <silent> t<C-l> :TestLast<CR>
nmap <silent> <S-F10> :TestLast<CR>
nmap <silent> t<C-g> :TestVisit<CR>
" }}}
"
"
"
" clang support ... for Debian Stretch only!{{{
"let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-3.8/lib/libclang.so.1'
"let g:deoplete#sources#clang#clang_header = '/usr/lib/llvm-3.8/lib/clang/3.8.1/include'
" works on Debian Buster anyway
let g:deoplete#sources#clang#clang_header = '/usr/lib/llvm-6.0/lib/clang/6.0.1/include/'
let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-6.0/lib/libclang.so.1'
"}}}
"
" deoplete omnifuc {{{
let g:deoplete#enable_at_startup = 1
let g:deoplete#disable_auto_complete = 0
"call deoplete#custom#option('auto_complete', 0)
"call deoplete#custom#source('jedi', 'debug_enabled', 1)
"call deoplete#enable_logging('DEBUG', '/tmp/deoplete.log')
"inoremap <silent><expr><C-Space> deoplete#mappings#manual_complete()
"}}}
"
" golang stuff {{{
let g:go_term_mode = "split"
let g:go_term_height = 10
"autocmd FileType go nmap <leader>r :w<CR>:split <bar> terminal go run %<CR>
autocmd FileType go nmap <leader>r :GoRun<CR>
" highlights the variable in the file for you..
"let g:go_auto_sameids = 1
" auto import...
let g:go_fmt_command = "goimports"
" automatic type info on cursor
let g:go_auto_type_info = 1
let g:go_snippet_engine = "neosnippet"
au Filetype go nmap <leader>ga <Plug>(go-alternate-edit)
au Filetype go nmap <leader>gah <Plug>(go-alternate-split)
au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical)
au FileType go nmap <F10> :GoTest -short<cr>
" }}}
"
" NEOSNIPPET
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"END OF NEOSNIPPET
"
" ultisnips... {{{
"inoremap <silent><expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
"let g:UltiSnipsExpandTrigger="<tab>"
"let g:UltiSnipsSnippetsDir = "/home/lemon/dotfiles/Ultisnips"
"let g:UltiSnipsSnippetDirectories=["/home/lemon/dotfiles/Ultisnips"]
"" let g:UltiSnipsJumpForwardTrigger="<c-n>"
"" let g:UltiSnipsJumpBackwardTrigger="<c-p>"
"let g:UltiSnipsJumpForwardTrigger="<c-j>"
"let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" }}}
"
" yapf - format python code (https://github.com/google/yapf)...{{{
map <leader>y :call yapf#YAPF()<cr>
imap <leader>y :call yapf#YAPF()<cr>
"autocmd FileType python nnoremap <leader>yy :0,$!yapf<Cr><C-o>
" ...}}}
"
" isort - sort python imports (https://github.com/timothycrosley/isort) ...{{{
let maplocalleader = "\\"
autocmd FileType python nnoremap <LocalLeader>j :!isort %<CR><CR>
" ...}}}
"
" Tabs, spaces, wrapping ...{{{
set tabstop=4
set shiftwidth=4
set shiftround
set softtabstop=4
set expandtab
set tw=79 " width of document(used by gd)
set nowrap "don't automatically wrap on load
set formatoptions=qrn1j
set fo-=t " don't automatically wrap text when typing
"set colorcolumn=+1
" ...}}}
"
" Enable folding ...{{{
set foldmethod=manual
set foldlevel=99
"...}}}
"
" Pymode stuff ...{{{
let g:pymode = 1
let g:pymode_options_colorcolumn = 0
" Python 3 syntax
let g:pymode_python = 'python3'
let g:pymode_rope = 1
let g:pymode_rope_completion = 0
let g:pymode_rope_complete_on_dot = 0
let g:pymode_rope_organize_imports_bind = '<C-c>ro'
let g:pymode_rope_enable_autoimport = 0
" Set quickfix window
let g:pymode_quickfix_minheight = 3
let g:pymode_quickfix_maxheight = 3
" Sort indentation
let g:pymode_indent = 1
" Documentation
let g:pymode_doc = 0
"let g:pymode_doc_key = 'K'
"Linting
let g:pymode_lint = 0
let g:pymode_lint_checker = "flake8"
" Auto check on save
let g:pymode_lint_write = 0
" Support virtualenv
let g:pymode_virtualenv = 1
let g:pymode_virtualenv_path = $VIRTUAL_ENV
"Enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
let g:pymode_breakpoint_cmd = 'breakpoint()'
"let g:pymode_breakpoint_cmd = 'from pdb import set_trace; set_trace()'
" more debug - this probably does pudb if you have that instead of ipdb
" map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
" syntax highlighting
let g:pymode_syntax = 0
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
" Don't autofold code
let g:pymode_folding = 0
" Rope rename
let g:pymode_rope_rename_bind = '<C-c>rr'
" Rope extract variable/method
let g:pymode_rope_extract_method_bind = '<C-c>rm'
let g:pymode_rope_extract_variable_bind = '<C-c>rl'
" SimplyFold config
let g:SimpylFold_docstring_preview=1 " docstrings for folded code
let python_highlight_all=1
" ...}}}
"
" Line return (make sure Vim goes where you left it ...{{{
" Make sure Vim returns to the same line when you reopen a file.
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
"}}}
"
"
" Backups ...{{{
set undodir=~/.nvim-tmp/tmp/undo// "undo files
set backupdir=~/.nvim-tmp/tmp/backup// " backups
set directory=~/.nvim-tmp/tmp/swap// " swap files
set backup " enable backups
"}}}
"
" Highlight VCS conflict markers ...{{{
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
"}}}
"
" Searching and movement ...{{{
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set gdefault
set scrolloff=3
set sidescroll=1
set sidescrolloff=10
set virtualedit+=block
nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
" search for the word you're looking at
nmap <M-k> :Ack! "\b<cword>\b" <CR>
"nmap <Esc>k :Ack! "\b<cword>\b" <CR>
nmap <M-S-k> :Ggrep! "\b<cword>\b" <CR>
"nmap <Esc>K :Ggrep! "\b<cword>\b" <CR>
nmap \x :cclose<CR>
" Don't move on *
nnoremap * *<c-o>
" Easier to type move extreme left and right
noremap H ^
noremap L g_
" Use ctrl-e and ctrl-a
inoremap <c-a> <esc>I
inoremap <c-e> <esc>A
" open a Quickfix window for the last search
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
"}}}
"
" Ag! ... {{{
nnoremap <leader>a :Ack!<space>
let g:ackprg = 'ag --smart-case --nogroup --nocolor --column'
" }}}
"
" Folding ... {{{
" Enable folding with the spacebar
nnoremap <space> za
nnoremap <leader>fm :set foldmethod=manual<CR>
" Make zO recursively open whatever fold we're in, even if it's partially open.
nnoremap zO zczO
" Use ,z to "focus" the current fold
nnoremap <leader>z zMzvzz
" }}}
"
"" Quick Editing ...{{{
nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr>
" }}}
"
" Convenience mappings ... {{{
" No more help key.
noremap <F1> :checktime<cr>
inoremap <F1> <esc>:checktime<cr>
" Kill window
"nnoremap <leader>K :q<cr>
" Wrap
nnoremap <leader>W :set wrap!<cr>
" Change case
noremap <C-u> gUiw
inoremap <C-u> <esc> gUiwea
" Substitute
nnoremap <leader>su :%s//<left>
nnoremap <Leader>s :%s/<C-r><C-w>//g<Left><Left>
"
" Emacs bindings in command line mode
cnoremap <c-a> <home>
cnoremap <c-e> <end>
" Turn off vimdiff
nnoremap <leader>D :diffoff!<cr>
" Formatting, like Textmate
nnoremap Q gqip
" Easier linewise reselection
nnoremap <leader>V V`]
" Split line (colleague of Join lines)
nnoremap S i<cr><esc><right>
" Source the current line
vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
" Select (charwise) the contents of the current line, excluding indentation.
" Great for pasting Python lines into REPLs.
nnoremap vv ^vg_
" }}}
"
" Ack motions ... {{{
" Motions to Ack for things. Works with pretty much everything, including:
"
" w, W, e, E, b, B, t*, f*, i*, a*, and custom text objects
"
" Awesome.
"
" Note: If the text covered by a motion contains a newline it won't work. Ack
" searches line-by-line.
nnoremap <silent> <leader>B :set opfunc=<SID>AckMotion<CR>g@
xnoremap <silent> <leader>B :<C-U>call <SID>AckMotion(visualmode())<CR>
"nnoremap <bs> :Ack! '\b<c-r><c-w>\b'<cr>
xnoremap <silent> <bs> :<C-U>call <SID>AckMotion(visualmode())<CR>
function! s:CopyMotionForType(type)
if a:type ==# 'v'
silent execute "normal! `<" . a:type . "`>y"
elseif a:type ==# 'char'
silent execute "normal! `[v`]y"
endif
endfunction
function! s:AckMotion(type) abort
let reg_save = @@
call s:CopyMotionForType(a:type)
execute "normal! :Ack! --literal " . shellescape(@@) . "\<cr>"
let @@ = reg_save
endfunction
" }}}
"
" Mutt ... {{{
augroup ft_muttrc
au!
au BufRead,BufNewFile *.muttrc set ft=muttrc
au FileType muttrc setlocal foldmethod=marker foldmarker={{{,}}}
augroup END
" }}}
"
" perldoc ... {{{
let g:perldoc_split_modifier = '10v'
"}}}
"
" vim-fugitive ... {{{
" prevent buffer build-up
autocmd BufReadPost fugitive://* set bufhidden=delete
"}}}
"
" ALE statusline ...{{{
"set statusline+=%{ALEGetStatusLine()}
"let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '• ok']
"let g:ale_linters = {'python': ['flake8'],}
"...}}}
"
" ale setting..{{{
"let g:ale_lint_on_text_changed = 'never'
" black config ...{{{
"let g:black_virtualenv = "/home/lemon/.virtualenvs/black-for-vim/"
"nmap <leader>l :Black<CR>
" LET'S RUN VIRTUALENV BLACK ON SAVE!
"autocmd BufWritePre *.py execute ':Black'
"let g:black_virtualenv = $VIRTUAL_ENV
" }}}
let g:ale_enabled = 1
let g:ale_sign_column_always = 1
let g:ale_open_list = 0
let g:ale_set_highlights = 1
let g:ale_set_signs = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%linter% - %code: %%s'
let g:ale_loclist_msg_format = '%linter% - %code: %%s'
let g:ale_echo_msg_warning_str = 'Warning'
"let g:ale_linters = {'python': ['flake8', 'mypy', 'pyls', 'pylint'],
"\ 'ocaml': ['merlin'],
" \}
let g:ale_linters = {'python': ['flake8', 'mypy'],
\ 'ocaml': ['merlin'],
\ 'cpp': ['clang'],
\ 'go': ['gometalinter', 'gofmt'],
\}
"let g:ale_linters_ignore = {'python': ['pyls']}
let g:ale_fixers = {'python': ['isort']} " we want to run black manually
let g:ale_python_mypy_ignore_invalid_syntax = 1
let g:ale_python_mypy_executable = 'mypy'
let g:ale_python_mypy_options = '--config-file mypy.ini'
" let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_fix_on_save = 1
let g:ale_linters_explicit = 0
" Mappings in the style of unimpaired-next
nmap [W <Plug>(ale_first)
nmap [w <Plug>(ale_previous)
nmap ]w <Plug>(ale_next)
nmap ]W <Plug>(ale_last)
" }}}
"
" More Haskell stuff - May 2017 ...{{{
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords}
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
"}}}
"
" Bufexplorer config ... {{{
let g:bufExplorerDefaultHelp=1 " Show default help.
let g:bufExplorerShowNoName=1 " Show "No Name" buffers.
let g:bufExplorerShowUnlisted=1 " Show unlisted buffers.
"}}}
"
" Django ... {{{
augroup ft_django
au!
au BufNewFile,BufRead urls.py setlocal nowrap
au BufNewFile,BufRead urls.py normal! zR
au BufNewFile,BufRead dashboard.py normal! zR
au BufNewFile,BufRead local_settings.py normal! zR
au BufNewFile,BufRead admin.py setlocal filetype=python.django
au BufNewFile,BufRead urls.py setlocal filetype=python.django
au BufNewFile,BufRead models.py setlocal filetype=python.django
au BufNewFile,BufRead views.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal foldmethod=marker
au BufNewFile,BufRead forms.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal foldmethod=marker
augroup END
" vim-markdown ...{{{
let g:vim_markdown_folding_disabled=1
set foldenable
let g:vim_markdown_initial_foldlevel=1
let g:vim_markdown_no_default_key_mappings=1
let g:vim_markdown_math=1
let g:vim_markdown_frontmatter=1
"}}}
"
" get rid of annoying Press ENTER prompts etc ...{{{
"set shortmess=atI
"}}}
"
" Remap movement in windows ...{{{
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
"}}}
"
nnoremap <Leader>c :set cursorline!<CR>
":nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
"}}}
"
" General python properness ...{{{
autocmd FileType python set sw=4
autocmd FileType python set ts=4
autocmd FileType python set sts=4
"}}}
"
" Escape sudo heck ...{{{
cmap w!! %!sudo tee > /dev/null %
"}}}
"
" Colorscheme ...{{{
"let g:github_colors_soft = "1
" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc
"color wombat256mod
"color Tomorrow-Night-Bright
"color monokai-phoenix
"colorscheme github
"colorscheme gruvbox
"color afterglow
colorscheme PaperColor
"
" if we are using default colorscheme, you want to switch off horrid
" grey gutter colour
highlight clear SignColumn
"
" Cursor and column highlighting ...{{{
" hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=#4b5260 guifg=white
" use guibg and guifg because I have set termguicolors switched on in this file
" The pythonSelf is a pymode thing...
"hi pythonSelf ctermfg=68 guifg=#5f87d7 cterm=bold gui=bold
"hi pythonSelf ctermfg=16 guifg=#5f87d7 cterm=bold gui=bold
"hi pythonNumber ctermfg=16 guifg=#aa4aef cterm=bold gui=bold
"hi pythonFloat ctermfg=16 guifg=#aa4aef cterm=bold gui=bold
"hi pythonHexNumber ctermfg=16 guifg=#aa4aef cterm=bold gui=bold
"
" my todo.todo... {{
autocmd BufNewFile,BufRead *.todo set syntax=markdown
"autocmd BufWritePost *.todo !todo-push
nmap <F2> a<C-R>=strftime("%c")<CR><Esc>
"let @d=':r! date _kb-I
ikb ($a)0"+dd:!xlcipkbkbkbkbclip -o >> /home/lemon/todo/done.todo
'
let @d='0$a(k2a)0"+dd:!xlcipkbkbkbkbclip -o >> /home/lemon/todo/done.todo
'
" ...}}
" Grepper ...{{{
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
" ...}}}
"
" FZF ...{{{
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" {{{ More fzf settings
" (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187)
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
nnoremap <C-p> :<C-u>FZF<CR>
nnoremap <leader><C-p> :<C-u>FZF!<CR>
nnoremap ; :Buffers<CR>
nnoremap <leader>t :Files<CR>
nnoremap <leader>o :Tags<CR>
nnoremap <leader>h :History<CR>
nnoremap <silent> <leader>0 :Files<CR>
nnoremap <silent> <leader>A :Windows<CR>
nnoremap <silent> <leader>; :BLines<CR>
nnoremap <silent> <leader>l :Lines<CR>
" nnoremap <silent> <leader># :Lines<CR>
nnoremap <silent> <leader>o :BTags<CR>
" command history is :History:
nnoremap <silent> <leader>? :History:<CR>
nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR>
" nnoremap <silent> <leader>. :AgIn #
" nnoremap <silent> <leader>a :Buffers<CR>
" nnoremap <silent> <leader>O :Tags<CR>
nnoremap <silent> <leader>P :call SearchWordWithAg()<CR>
vnoremap <silent> <leader>P :call SearchVisualSelectionWithAg()<CR>
" nnoremap <silent> <leader>gl :Commits<CR>
" nnoremap <silent> <leader>ga :BCommits<CR>
nnoremap <silent> <leader>ft :Filetypes<CR>
imap <C-x><C-f> <plug>(fzf-complete-file-ag)
imap <C-x><C-l> <plug>(fzf-complete-line)
function! SearchWordWithAg()
execute 'Ag' expand('<cword>')
endfunction
function! SearchVisualSelectionWithAg() range
let old_reg = getreg('"')
let old_regtype = getregtype('"')
let old_clipboard = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', old_reg, old_regtype)
let &clipboard = old_clipboard
execute 'Ag' selection
endfunction
" function! SearchWithAgInDirectory(...)
" call fzf#vim#ag(join(a:000[1:], ' '), extend({'dir': a:1}, g:fzf#vim#default_layout))
" endfunction
" command! -nargs=+ -complete=dir AgIn call SearchWithAgInDirectory(<f-args>)
" }}}
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
"
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'}
" ...}}}
"
" Ocaml/merlin
"let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
"execute "set rtp+=" . g:opamshare . "/merlin/vim"
"set rtp^="/home/lemon/.opam/4.06.1/share/ocp-indent/vim"
"
" Search from git root via :Rag (Root Ag)
" Thanks! https://github.com/fortes/dotfiles/blob/7ba6ea651edde8fbc24fdf9df52ba06f7e956efc/stowed-files/nvim/.vimrc
" :Rag - hidden preview enabled with "?" key
" :Rag! - fullscreen and preview window above
" Change to git root of current file (if in a repo)
function! FindGitRootCD()
let root = systemlist('git -C ' . expand('%:p:h') . ' rev-parse --show-toplevel')[0]
if v:shell_error
return ''
else
return {'dir': root}
endif
endfunction
function! GitRootCD()
let result = FindGitRootCD()
if type(result) == type({})
execute 'lcd' fnameescape(result['dir'])
echo 'Now in '.result['dir']
else
echo 'Not in git repo!'
endif
endfunction
command! GitRootCD :call GitRootCD()
command! -bang -nargs=* Rag
\ call GitRootCD() | call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%', '?')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Use fuzzy searching for K & Q, select items to go into quickfix
nnoremap L :Rag! <C-R><C-W><cr>
vnoremap L :<C-u>norm! gv"sy<cr>:silent! Rag! <C-R>s<cr>
nnoremap Q :Rag!<SPACE>
"highlight ColorColumn ctermbg=0
highlight NonText cterm=NONE
|