-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnvimrc
828 lines (697 loc) · 28.5 KB
/
nvimrc
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
call plug#begin('~/.vim/plugged')
" Better Settings
Plug 'https://github.com/tpope/vim-sensible.git'
Plug 'https://github.com/jeffkreeftmeijer/vim-numbertoggle.git' " smart setting of number and relative number
" Completion
Plug 'https://github.com/neovim/nvim-lspconfig.git' " TODO: check in wiki for many more improvements
" More: https://github.com/Shougo/deoplete.nvim/wiki/Completion-Sources
Plug 'https://github.com/Shougo/deoplete.nvim.git'
Plug 'https://github.com/Shougo/neco-vim.git' " vim source for Vim script
Plug 'https://github.com/Shougo/neoinclude.vim.git' " include and file/include sources
Plug 'https://github.com/Shougo/neco-syntax.git' " syntax source
Plug 'https://github.com/deoplete-plugins/deoplete-jedi' " pythom source
"Plug 'https://github.com/kristijanhusak/vim-dadbod-completion' " SQL
Plug 'https://github.com/deoplete-plugins/deoplete-lsp.git'
Plug 'https://github.com/deoplete-plugins/deoplete-docker.git'
Plug 'https://github.com/ervandew/supertab.git'
let g:SuperTabDefaultCompletionType = "<c-n>" " Make the tabing on completion menu go from top to bottom
let g:SuperTabClosePreviewOnPopupClose = 1 " Close the preview when completion ends
" Snippets
Plug 'https://github.com/sirver/ultisnips.git'
" Don't map any tabs, I'll do it later
let g:UltiSnipsExpandTrigger = '<NOP>'
let g:UltiSnipsJumpForwardTrigger = '<NOP>'
let g:UltiSnipsJumpBackwardTrigger = '<NOP>'
let g:SuperTabMappingBackward = '<NOP>'
" Don't unmap my mappings
let g:UltiSnipsMappingsToIgnore = [ "SmartTab", "SmartShiftTab" ]
" Make <CR> smart
let g:ulti_expand_res = 0
function! Ulti_ExpandOrEnter()
" First try to expand a snippet
call UltiSnips#ExpandSnippet()
if g:ulti_expand_res
" if successful, just return
return ''
elseif pumvisible()
" if in completion menu - just close it and leave the cursor at the
" end of the completion
return deoplete#close_popup()
else
" otherwise, just do an "enter"
return "\<return>"
endif
endfunction
inoremap <return> <C-R>=Ulti_ExpandOrEnter()<CR>
" Enable tabbing and shift-tabbing through list of results
function! g:SmartTab()
if pumvisible()
return SuperTab("n")
else
call UltiSnips#JumpForwards()
if g:ulti_jump_forwards_res == 0
return SuperTab("n")
endif
return ''
endif
endfunction
inoremap <silent> <tab> <C-R>=g:SmartTab()<cr>
snoremap <silent> <tab> <Esc>:call g:SmartTab()<cr>
function! g:SmartShiftTab()
if pumvisible()
return SuperTab("p")
else
call UltiSnips#JumpBackwards()
if g:ulti_jump_backwards_res == 0
return SuperTab("p")
endif
return ''
endif
endfunction
inoremap <silent> <s-tab> <C-R>=g:SmartShiftTab()<cr>
snoremap <silent> <s-tab> <Esc>:call g:SmartShiftTab()<cr>
Plug 'https://github.com/honza/vim-snippets.git'
" Static Analysis
Plug 'https://github.com/neomake/neomake.git'
" Apperance
Plug 'https://github.com/morhetz/gruvbox.git'
Plug 'https://github.com/vim-airline/vim-airline.git'
Plug 'https://github.com/vim-airline/vim-airline-themes.git'
"Plug 'https://github.com/bling/vim-bufferline.git' -
Plug 'https://github.com/lukas-reineke/indent-blankline.nvim.git'
Plug 'ryanoasis/vim-devicons' " add nice icons to the status line, tabline, etc.
" Movement & Search
Plug 'https://github.com/haya14busa/incsearch.vim.git'
Plug 'https://github.com/haya14busa/incsearch-fuzzy.vim.git'
Plug 'https://github.com/justinmk/vim-sneak.git'
Plug 'https://github.com/tpope/vim-unimpaired.git' " pairs of handy bracket mappings - use: [ with q,a,b,<space>,x,u,y,f,n
Plug 'https://github.com/mhinz/vim-grepper.git', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
let g:grepper = {}
let g:grepper.dir = 'repo,file'
let g:grepper.tools = ['rg', 'ag', 'git', 'grep']
autocmd! User vim-grepper let g:grepper.git.grepprg .= ' --no-color'
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
nnoremap <leader>* :Grepper -tool rg -open -switch -cword -noprompt<cr>
command! Todo Grepper -noprompt -tool git -query -E '(TODO|FIXME|XXX):'
"""""""""""
" Editing "
"""""""""""
Plug 'https://github.com/numToStr/Comment.nvim.git' " Better commenting of code
Plug 'https://github.com/tpope/vim-surround.git' " TODO: learn to use
Plug 'https://github.com/jiangmiao/auto-pairs.git' " Use <a-e> to toggle autopairs
Plug 'https://github.com/tpope/vim-speeddating.git' " use CTRL-A/CTRL-X to increment dates, times, and more - TODO: learn to use
" Use SpeedDatingFormat! for help defining new formats
" http://www.thegeekstuff.com/2009/10/vim-editor-how-to-increase-or-decrease-date-time-roman-number-and-ordinals/
"Plug 'https://github.com/mjbrownie/swapit.git' " increment/swap different types like true/false TODO: test
"Plug 'https://github.com/mattn/emmet-vim.git' " TODO: learn to use
Plug 'https://github.com/tpope/vim-characterize.git'
Plug 'https://github.com/ntpeters/vim-better-whitespace.git'
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
let g:show_spaces_that_precede_tabs=1
nnoremap ]w :NextTrailingWhitespace<CR>
nnoremap [w :PrevTrailingWhitespace<CR>
"Plug 'https://github.com/mg979/vim-visual-multi.git' " TODO: learn to use
"" disable deoplate when using multiplae cursors (see: https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L1070)
"function g:Multiple_cursors_before()
" let g:deoplete#disable_auto_complete = 1
"endfunction
"function g:Multiple_cursors_after()
" let g:deoplete#disable_auto_complete = 0
"endfunction
" Text objects
Plug 'https://github.com/kana/vim-textobj-user.git' " Needed to define custom text objects
Plug 'https://github.com/michaeljsmith/vim-indent-object.git' " Indentation level text object (i & I)
Plug 'https://github.com/rhysd/vim-textobj-anyblock' " Use b to for the closest of '', \"\", (), {}, [] and <>
Plug 'https://github.com/Chiel92/vim-autoformat.git' " Reformat files
"checkout https://github.com/sbdchd/neoformat instead of previous...
"Plug 'https://github.com/foosoft/vim-argwrap.git' " TODO: learn to use and define mapping
Plug 'https://github.com/dhruvasagar/vim-table-mode.git' " For working with tables, Lazy load when using TableModeToggle - TODO: learn to use
" Help
Plug 'https://github.com/rizzatti/dash.vim' " TODO: learn to use
"
" Git
"
Plug 'https://github.com/tpope/vim-git.git'
Plug 'https://github.com/tpope/vim-fugitive.git' " Git integration - TODO: learn to use
Plug 'https://github.com/tpope/vim-rhubarb.git' " Github integration for fugitive
Plug 'https://github.com/airblade/vim-gitgutter.git'
Plug 'https://github.com/rhysd/committia.vim.git' " Better commiting messageing
Plug 'https://github.com/APZelos/blamer.nvim.git'
let g:blamer_enabled = 1
Plug 'https://github.com/rhysd/git-messenger.vim.git', {'on': ['GitMessenger', '<Plug>(git-messenger']}
" Commita config
let g:committia_open_only_vim_starting = 1
let g:committia_hooks = {}
function! g:committia_hooks.edit_open(info)
" Additional settings
setlocal spell
" If no commit message, start with insert mode
if a:info.vcs ==# 'git' && getline(1) ==# ''
startinsert
end
" Scroll the diff window from insert mode
" Map <C-n> and <C-p>
imap <buffer><C-n> <Plug>(committia-scroll-diff-down-half)
imap <buffer><C-p> <Plug>(committia-scroll-diff-up-half)
endfunction
" General improvements
Plug 'https://github.com/tpope/vim-repeat.git' " Better .
Plug 'https://github.com/svermeulen/vim-easyclip.git' " Better clipboard - TODO: learn to use
Plug 'https://github.com/kopischke/vim-fetch.git' " Open file on line and character
"Plug 'https://github.com/junegunn/vim-peekaboo.git' " Register helper - TODO: learn to use - perhaps remove as whichkey gives the functionality
Plug 'https://github.com/majutsushi/tagbar.git' " Display tags in a window - TODO: learn to use
Plug 'https://github.com/jeetsukumaran/vim-buffergator.git' " List, select and switch between buffers - TODO: learn to use
Plug 'https://github.com/amiorin/vim-project.git' " TODO: learn to use
Plug 'https://github.com/tpope/vim-eunuch.git' " helpers commands for UNIX - TODO: learn to use
"Plug 'https://github.com/tpope/vim-sleuth.git' - TODO: test and learn
" Plugin creating helpers
Plug 'https://github.com/vim-jp/vital.vim.git'
":Vitalize --name=cheatsheet /Users/simonweil/mine/projects/cheatsheet.vim Web.JSON
"https://github.com/mattn/webapi-vim
"https://github.com/google/vim-maktaba
"https://github.com/google/vim-glaive
""""""""""""""""
" Fuzzy Things "
""""""""""""""""
Plug '/usr/local/opt/fzf'
Plug 'https://github.com/junegunn/fzf.vim.git'
let g:fzf_commits_log_options = '--color=always --pretty=format:"%Cred%h%Creset - %s %Cgreen(%cr)%Creset by %C(bold blue)%an%C(yellow)%d%Creset" --abbrev-commit --date=relative'
Plug 'https://github.com/voldikss/vim-floaterm.git'
let g:floaterm_width = 0.8
let g:floaterm_height = 0.8
let g:floaterm_opener = 'edit'
let g:floaterm_keymap_new = '<F5>'
let g:floaterm_keymap_toggle = '<F6>'
" Install plugin dependencies
Plug 'https://github.com/kyazdani42/nvim-web-devicons.git'
Plug 'https://github.com/nvim-treesitter/nvim-treesitter.git', {'do': ':TSUpdate'}
Plug 'https://github.com/nvim-lua/popup.nvim.git'
Plug 'https://github.com/nvim-lua/plenary.nvim.git'
"
" Install Telescope
Plug 'https://github.com/nvim-telescope/telescope.nvim.git'
Plug 'https://github.com/nvim-telescope/telescope-fzf-native.nvim.git', { 'do': 'make' }
Plug 'https://github.com/xiyaowong/telescope-emoji.nvim.git'
Plug 'https://github.com/ANGkeith/telescope-terraform-doc.nvim.git'
" Navigation and work assistance
Plug 'https://github.com/kyazdani42/nvim-tree.lua.git'
Plug 'https://github.com/sudormrfbin/cheatsheet.nvim.git'
Plug 'https://github.com/folke/which-key.nvim.git'
""""""""""""""""""""
" External plugins "
""""""""""""""""""""
" Plug 'https://github.com/glacambre/firenvim.git', { 'do': function('firenvim#install') }
"
" " Exclude from intercom chats and google docs
" let g:firenvim_config = {
" \ 'localSettings': {
" \ '.*': {
" \ 'selector': '*:not(.intercom-composer) > textarea',
" \ 'priority': 0,
" \ },
" \ 'docs\.google\.com': {
" \ 'selector': '',
" \ 'priority': 1,
" \ },
" \ '.*\.atlassian.net': {
" \ 'selector': '',
" \ 'priority': 1,
" \ },
" \ }
" \ }
"
" if exists('g:started_by_firenvim')
" " Make github textareas be with markdown syntax
" au BufEnter github.com_*.txt set filetype=markdown
"
" " Allow moving focus back to the page with double esc
" nnoremap <Esc><Esc> :call firenvim#focus_page()<CR>
"
" " Write the buffer contents back to the page all the time automaticly
" au TextChanged * ++nested write
" au TextChangedI * ++nested write
" endif
""""""""""""""""""""
" Languge Specific "
""""""""""""""""""""
" language pack, look here to find language plugins
Plug 'https://github.com/sheerun/vim-polyglot.git'
"https://github.com/vim-python/python-syntax - TODO: check that settings are good for me
let g:polyglot_disabled = ['ruby', 'puppet']
" Set filetype in by context in of the file (e.g. javascript tag in an html file)
"Plug 'https://github.com/Shougo/context_filetype.vim.git' - TODO: test!
" SQL
"Plug 'https://github.com/tpope/vim-dadbod'
"Plug 'https://github.com/kristijanhusak/vim-dadbod-ui'
" Ruby
Plug 'https://github.com/vim-ruby/vim-ruby.git', {'for': 'ruby'}
Plug 'https://github.com/tpope/vim-endwise.git', {'for': 'ruby'}
Plug 'https://github.com/tpope/vim-rails.git', {'for': 'ruby'}
Plug 'https://github.com/tpope/vim-bundler.git', {'for': 'ruby'}
Plug 'https://github.com/depuracao/vim-rdoc.git', {'for': 'ruby'}
"Plug 'https://github.com/skwp/vim-rspec.git'
"Plug 'https://github.com/sunaku/vim-ruby-minitest.git'
"Plug 'https://github.com/skalnik/vim-vroom.git'
"Plug 'https://github.com/slim-template/vim-slim.git'
"Plug 'https://github.com/tpope/vim-haml.git'
"Plug 'https://github.com/tpope/vim-cucumber.git'
"Plug 'https://github.com/noprompt/vim-yardoc.git'
" Python
Plug 'https://github.com/mjbrownie/django-template-textobjects.git' " TODO: learn to use
" JavaScript
Plug 'https://github.com/pangloss/vim-javascript.git' " TODO: keep? or use polyglot
Plug 'https://github.com/maksimr/vim-jsbeautify.git'
Plug 'https://github.com/mmalecki/vim-node.js.git' " TODO: keep? or use polyglot
Plug 'https://github.com/mxw/vim-jsx.git' " TODO: keep? or use polyglot
"Plug 'https://github.com/marijnh/tern_for_vim.git'
"Plug 'https://github.com/kchmck/vim-coffee-script.git'
" Markdown
Plug 'https://github.com/tpope/vim-markdown.git' " TODO: test
Plug 'https://github.com/shime/vim-livedown.git' " TODO: test
" SCSS / CSS
Plug 'https://github.com/ap/vim-css-color.git'
Plug 'https://github.com/JulesWang/css.vim.git' " TODO: keep? or use polyglot
Plug 'https://github.com/cakebaker/scss-syntax.vim.git' " TODO: keep? or use polyglot
" CSV
Plug 'https://github.com/chrisbra/csv.vim.git'
" PHP
"Plug 'https://github.com/StanAngeloff/php.vim.git'
"https://github.com/phpvim/phpcd.vim
" Configuration files
Plug 'https://github.com/rodjek/vim-puppet.git', {'for': 'puppet'}
"Check and add
"https://github.com/raghur/vim-ghost
"https://github.com/jalvesaq/vimcmdline
"https://github.com/hardenedapple/vsh
"https://github.com/lucc/nvimpager
"https://github.com/cyansprite/Extract
"https://github.com/krisajenkins/vim-projectlocal
"https://github.com/Vigemus/nvimux
"https://gitlab.com/HiPhish/repl.nvim
"https://github.com/neoclide/coc.nvim - LSP support
"https://github.com/brooth/far.vim - better find/replace
"https://github.com/jsfaint/gen_tags.vim
"https://github.com/kassio/neoterm - better terminal
"https://github.com/brettanomyces/nvim-editcommand
"https://github.com/numirias/semshi
"https://github.com/tek/proteome
"https://github.com/teto/nvim-palette
"https://github.com/bfredl/nvim-miniyank
"https://github.com/bfredl/nvim-ipy
"https://github.com/brettanomyces/nvim-terminus
"https://github.com/sheerun/vim-polyglot
"https://github.com/Shougo/denite.nvim
"Plug 'https://github.com/xolox/vim-easytags.git'
"Plug 'https://github.com/scrooloose/nerdcommenter.git'
"Plug 'https://github.com/itspriddle/ZoomWin.git'
"Plug 'https://github.com/mileszs/ack.vim.git'
"https://github.com/mbbill/undotree.git
"Plug 'https://github.com/scrooloose/nerdtree.git'
"Plug 'https://github.com/mattn/webapi-vim.git' - plugin development
"Plug 'https://github.com/mattn/gist-vim.git'
"Plug 'https://github.com/vim-scripts/vimwiki.git'
"""Plug 'https://github.com/chrisbra/NrrwRgn.git'
"Plug 'https://github.com/rgarver/Kwbd.vim.git'
"Plug 'https://github.com/kien/ctrlp.vim.git'
"Plug 'https://github.com/thinca/vim-visualstar.git'
"Plugin 'jalcine/snipmate-nodejs'
"Plugin 'gorodinskiy/vim-coloresque'
"Plugin 'dbakker/vim-lint'
"Plugin 'editorconfig/editorconfig-vim'
"Plugin 'gmarik/github-search.vim'
"Plugin 'godlygeek/tabular'
"Plugin 'int3/vim-extradite'
"Plugin 'jaxbot/github-issues.vim'
"Plugin 'brettof86/vim-swigjs'
"Plugin 'junegunn/vim-github-dashboard'
"Plugin 'kshenoy/vim-signature'
"Plugin 'majutsushi/tagbar'
"Plugin 'mattn/gist-vim'
"Plugin 'mmozuras/vim-github-comment'
"Plugin 'perl-support.vim'
"Plugin 'syngan/vim-vimlint'
"https://github.com/dbakker/vim-lint
"Plugin 'tfnico/vim-gradle'
"Plugin 'thinca/vim-localrc'
"Plugin 'vim-perl/vim-perl'
"Plugin 'xolox/vim-easytags'
"Plugin 'xolox/vim-misc'
"Plugin 'xolox/vim-notes'
"Plugin 'xolox/vim-publish'
"Plugin 'xolox/vim-session'
"Plugin 'rayburgemeestre/phpfolding.vim'
"Plugin 'shawncplus/phpcomplete.vim'
"Plugin 'heavenshell/vim-slack'
"Plugin 'tpope/vim-rsi'
"Plugin 'Xuyuanp/nerdtree-git-plugin'
"Plugin 'jszakmeister/vim-togglecursor'
"Plugin 'TagHighlight'
"Plugin 'taglist.vim'
"Plugin 'tpope/vim-rbenv'
"Plugin 'chase/vim-ansible-yaml'
"Plugin 'vim-ruby/vim-ruby'
"Plugin 'guns/xterm-color-table.vim'
"Plugin 'marijnh/tern_for_vim'
"Plugin 'flazz/vim-colorschemes'
"Plugin 'tmatilai/vim-monit'
"Plugin 'SyntaxRange'
"Plugin 'farseer90718/vim-taskwarrior'
"Plugin 'KabbAmine/vCoolor.vim'
"Plugin 'fatih/vim-go'
"https://github.com/vim-ctrlspace/vim-ctrlspace
"https://github.com/edkolev/promptline.vim
" Use patience algorithm for vim diff
set diffopt+=internal,algorithm:patience
call plug#end()
" = Vimscript file settings = {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker keywordprg=:help
autocmd Filetype vim setlocal softtabstop=2 shiftwidth=2 smarttab
augroup END
" }}}
" = Better settings = {{{
" Set leader key
let mapleader="`"
let maplocalleader="'"
" Highlight the screen line of the cursor
set cursorline
" Allow moving the mouse on the whole screen
set virtualedit=all
" Allow tabbed menu for completion in command mode (:)
set wildmenu
" Make y, p and d work with the clipboard
set clipboard=unnamed
" Show numbers by default
set number
" Show a 120 column width indicator
set colorcolumn=120
highlight ColorColumn ctermbg=12 guibg=Red
au FileType help,qf,netrw,location,git setlocal colorcolumn=
" highlight search results
set hlsearch
" make "tab" insert indents instead of tabs at the beginning of a line
set smarttab
" always uses spaces instead of tab characters
set expandtab
" Spelling
if !&readonly
augroup spellcheck
autocmd!
autocmd FileType markdown setlocal spell complete+=kspell
augroup END
endif
let &spellfile = $HOME . "/.dotfiles/vim/dictionary.en.add"
" Turn on true colors
set termguicolors
" Turn on live substitute
set inccommand=split
" Python executables
let g:python3_host_prog = $VENV_HOME . '/neovim/bin/python'
let g:perl_host_prog = '/opt/homebrew/bin/perl'
" }}}
" = Mappings = {{{
" ================
" Pressing kj to avoid esc for quiting insert mode
inoremap kj <Esc>l
" Make Y work like D, M, C
nnoremap Y y$
" Set marks with <localleader>m as m is used by easyclip for move (cut)
nnoremap <LocalLeader>m m
" Jump to marks with <localleader>` as ` is the localleader
nnoremap <LocalLeader>` `
" allow j and k to go up or down by visual lines rether than actual lines
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" display all lines with keyword under cursor
" and ask which one to jump to
nmap <LocalLeader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" find git merge conflict markers
nnoremap <LocalLeader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" Underline the current line with any char or a specific rule in specific filetypes
function! UnderlineCurrentLine(...) abort
let line = getline('.')
" For markdown files, underline headers of tables specially
if &filetype ==? "markdown" && line[0] == '|' && line[len(line)-1] == '|'
execute "normal! :t.\<CR>:s/[^|]/-/g\<CR>"
return
endif
let _c = getchar()
let c = type(_c) == type(0) ? nr2char(_c) : _c
if c ==# "\<Esc>" || c == "\<C-c>"
return
endif
execute "normal! :t.\<CR>Vr" . c
" In insert mode end on the next line back in insert mode
if a:0 == 1 && a:1 ==? "i"
normal! o
startinsert
endif
endfunction
nmap <silent> <leader>ul :call UnderlineCurrentLine()<CR>
imap <silent> <leader>ul <ESC>:call UnderlineCurrentLine("i")<CR>
" }}}
" Use a special color scheme for MacVim GUI
colorscheme gruvbox
set background=dark
" search google with the word under the cursor
nmap <LocalLeader>g :call Google()<CR>
fun! Google()
let keyword = expand("<cword>")
let url = "http://www.google.com/search?q=" . keyword
let path = ""
exec 'silent !"' . path . 'open" ' . url
endfun
" = Plugins setup = {{{
" =====================
lua << EOF
require('nvim-web-devicons').setup()
require('telescope').setup()
require('telescope').load_extension('fzf')
require('telescope').load_extension('emoji')
require('telescope').load_extension('terraform_doc')
require('nvim-tree').setup()
require("which-key").setup()
-- Config: https://github.com/numToStr/Comment.nvim#configuration-optional
require('Comment').setup()
EOF
" Keymaps
nnoremap gtf :Telescope terraform_doc full_name=hashicorp/aws version=3.74.3<cr>
nnoremap gof :Telescope oldfiles<cr>
nnoremap gob :FloatermNew broot<cr>
"nnoremap <F1> :Telescope project<cr>
nnoremap <F2> :Telescope git_files<cr>
nnoremap <F3> :Telescope commands<cr>
nnoremap <F4> :Telescope buffers<cr>
nnoremap <F9> :NvimTreeToggle<CR>
" Telescope
autocmd FileType TelescopePrompt call deoplete#custom#buffer_option('auto_complete', v:false)
"""""""""""""""""""""""""
" Vim Plug Improvements "
"""""""""""""""""""""""""
function! s:plug_doc()
let name = matchstr(getline('.'), '^- \zs\S\+\ze:')
if has_key(g:plugs, name)
for doc in split(globpath(g:plugs[name].dir, 'doc/*.txt'), '\n')
execute 'tabe' doc
endfor
endif
endfunction
function! s:plug_gx()
let line = getline('.')
let sha = matchstr(line, '^ \X*\zs\x\{7,9}\ze ')
let name = empty(sha) ? matchstr(line, '^[-x+] \zs[^:]\+\ze:')
\ : getline(search('^- .*:$', 'bn'))[2:-2]
let uri = get(get(g:plugs, name, {}), 'uri', '')
if uri !~ 'github.com'
return
endif
let repo = matchstr(uri, '[^:/]*/'.name)
let url = empty(sha) ? 'https://github.com/'.repo
\ : printf('https://github.com/%s/commit/%s', repo, sha)
call netrw#BrowseX(url, 0)
endfunction
augroup PlugGx
autocmd!
autocmd FileType vim-plug nnoremap <buffer> <silent> gx :call <sid>plug_gx()<cr>
autocmd FileType vim-plug nnoremap <buffer> <silent> H :call <sid>plug_doc()<cr>
augroup END
" }}}
" = NeoVim Specific Settings = {{{
" ================================
if has('nvim')
" = Terminal specific settings = {{{
" ==================================
" allow terminal buffer size to be very large
let g:terminal_scrollback_buffer_size = 100000
" map esc to exit to normal mode in terminal too
tnoremap <Esc><Esc> <C-\><C-n>
" make window commads work in the terminal from the insert mode
"tnoremap <c-w> <C-\><C-n><c-w> - disabled as this prevents terminal <c-w> which deletes a word
augroup terminal_vim
autocmd!
autocmd WinEnter term://* startinsert
augroup END
" }}}
" = Terminal and Splits movment and creation = {{{
" ================================================
" Move between splits
tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
tnoremap <A-c> <C-\><C-n><C-w>c
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
nnoremap <A-c> <C-w>c
" New split creation
tnoremap <A-d> <C-\><C-n>:vsp<bar>enew<CR>
tnoremap <A-s-d> <C-\><C-n>:sp<bar>enew<CR>
inoremap <A-d> <ESC>:vsp<bar>enew<CR>
inoremap <A-s-d> <ESC>:sp<bar>enew<CR>
nnoremap <A-d> :vsp<bar>enew<CR>
nnoremap <A-s-d> :sp<bar>enew<CR>
" New terminal creation
tnoremap <A-t> <C-\><C-n>:vsp<bar>enew<bar>call termopen("bash -l")<CR>
tnoremap <A-s-t> <C-\><C-n>:sp<bar>enew<bar>call termopen("bash -l")<CR>
inoremap <A-t> <ESC>:vsp<bar>enew<bar>call termopen("bash -l")<CR>
inoremap <A-s-t> <ESC>:sp<bar>enew<bar>call termopen("bash -l")<CR>
nnoremap <A-t> :vsp<bar>enew<bar>call termopen("bash -l")<CR>
nnoremap <A-s-t> :sp<bar>enew<bar>call termopen("bash -l")<CR>
" }}}
" = Lua stuff = {{{
" =================
augroup LuaHighlight
autocmd!
autocmd TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=300}
augroup END
" }}}
endif
" }}}
" vimrc helpers
nnoremap <localleader>sv :source ~/.config/nvim/init.vim<cr>
nnoremap <localleader>eva :vsplit ~/.config/nvim/init.vim<cr>
" Deoplate
let deoplete#sources#jedi#show_docstring = 1
let g:deoplete#enable_at_startup = 1
let g:deoplete#lsp#use_icons_for_candidates = v:true
call deoplete#custom#option({
\ 'smart_case': v:true,
\ 'num_processes': 0,
\ })
" Setup LSP servers
" Configurations: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
" Possible: SQL, CSS, HTML
lua << EOF
local lspconfig = require 'lspconfig'
local on_attach = function(_, bufnr)
local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
end
local servers = { 'bashls', 'dockerls', 'jsonls', 'vimls', 'jedi_language_server', 'terraformls' }
-- removed 'terraformls', as it makes the editor slow
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
}
end
EOF
autocmd BufWritePre *.tf lua vim.lsp.buf.format({ async = false })
" Indent Settings
let g:indent_blankline_filetype_exclude = ['help', 'nerdtree', 'git', 'vim-plug', 'man', 'lspinfo', 'packer', 'checkhealth', 'NvimTree']
let g:indent_blankline_use_treesitter_scope = v:true
" Number Toggle
let g:NumberToggleTrigger="<localleader>n"
" Multiple Cursors
let g:multi_cursor_next_key='<A-S-n>'
let g:multi_cursor_prev_key='<A-S-p>'
let g:multi_cursor_skip_key='<A-S-x>'
"let g:multi_cursor_quit_key='<Esc>'
" Airline plugin
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#hunks#enabled = 1
let g:airline#extensions#grepper#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_theme='luna'
" remove the buffer list from the command line
let g:bufferline_echo = 0
" Tagbar
nmap <F8> :TagbarToggle<CR>
" = neomake = {{{
" ===============
" You can then navigate them using the built-in methods like :lwindow / :lopen (to view the list) and :lprev / :lnext to go back and forth.
call neomake#configure#automake('nrwi', 200)
" }}}
" = incsearch = {{{
" ========================
" TODO: Maybe switch to https://github.com/junegunn/vim-oblique
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" Turn off high lighting automaticly
" :h g:incsearch#auto_nohlsearch
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
" Fuzzy Searching
function! s:config_fuzzyall(...) abort
return extend(copy({
\ 'converters': [
\ incsearch#config#fuzzy#converter(),
\ incsearch#config#fuzzyspell#converter()
\ ],
\ }), get(a:, 1, {}))
endfunction
noremap <silent><expr> z/ incsearch#go(<SID>config_fuzzyall())
noremap <silent><expr> z? incsearch#go(<SID>config_fuzzyall({'command': '?'}))
noremap <silent><expr> zg? incsearch#go(<SID>config_fuzzyall({'is_stay': 1}))
" }}}
" = Fugitive = {{{
" ========================
nmap <localleader>gb :Gblame<CR>
nmap <localleader>gs :Gstatus<CR>
nmap <localleader>gd :Gdiff<CR>
nmap <localleader>gl :Glog<CR>
nmap <localleader>gc :Gcommit<CR>
" }}}
" Mappings for the Dash.app
nmap <silent> <localleader>d <Plug>DashSearch
" Mapping to open Markdown preview (vim-livedown)
nmap gm :LivedownToggle<CR>
" Setting tab witdh by file type
autocmd Filetype html setlocal tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab
autocmd Filetype javascript setlocal tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab
autocmd Filetype yaml setlocal tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab
if has('dontdoathis') " TODO: do I need this?
" ----------------------------------------------------------
" setup the projects: https://github.com/amiorin/vim-project
" ----------------------------------------------------------
" Set my starting path
call project#rc("~/work/")
" My projects
Project '~/mine/dev/Community' , 'Community'
Project '~/.dotfiles' , 'My DotFiles :)'
endif