-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
1489 lines (1181 loc) · 40.8 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
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
" change leader to space
" required before plugin loads to ensure they configure correctly
let mapleader=" "
""""""""""
" PLUGINS
""""""""""
call plug#begin()
" basic setup for all vim
Plug 'tpope/vim-sensible'
" extend the power of . to more complex objects
Plug 'tpope/vim-repeat'
" git integration. seems to have the most mindshare
Plug 'tpope/vim-fugitive'
" disabled for now for performance reasons
" Plug 'jreybert/vimagit'
" github support for fugative
Plug 'tpope/vim-rhubarb'
" map s so that vim-cutlass doesn't override it
nmap s <nop>
" sanity to copy/paste
Plug 'svermeulen/vim-cutlass'
Plug 'svermeulen/vim-yoink'
" Plug 'svermeulen/vim-subversive'
" unmap s so that lightspeed now WILL override it
unmap s
" sneek - simpler alternative to easymotion or a better f
" Plug 'justinmk/vim-sneak'
Plug 'ggandor/lightspeed.nvim'
nmap s <Plug>Lightspeed_s
nmap S <Plug>Lightspeed_S
" git gutter. []c to navigate change hunks
" <leader>hs to stage hunk
Plug 'airblade/vim-gitgutter'
" lightweight and independent statusline plugin
Plug 'itchyny/lightline.vim'
" auto quote/bracket/paren matching
" Plug 'jiangmiao/auto-pairs'
" Plug 'Townk/vim-autoclose'
Plug 'Raimondi/delimitMate'
" modernize %
Plug 'andymass/vim-matchup'
" motions/text objects for surrounding selections with chars
Plug 'tpope/vim-surround'
" plugin management QOL from tpope
" zS to show active syntax highlight group
Plug 'tpope/vim-scriptease'
" provides mixed case abbreviations and searches
Plug 'tpope/vim-abolish'
" wrapper around ag for project wide search
Plug 'mileszs/ack.vim'
" allow vim<->tmux pane navigation
Plug 'christoomey/vim-tmux-navigator'
Plug 'ludovicchabant/vim-gutentags'
" better bdelete
Plug 'moll/vim-bbye'
" gave in and using nerdtree rather than netrw
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" consider this as a replacement for NERDTree
" Plug 'kyazdani42/nvim-tree.lua'
" add motions for word hunks in camel or underscore case
Plug 'chaoren/vim-wordmotion'
" lots of targets
" separators, args, etc
Plug 'wellle/targets.vim'
" adds indent level as an object
Plug 'michaeljsmith/vim-indent-object'
" Plug 'kana/vim-textobj-user'
" Plug 'bps/vim-textobj-python'
" adds text objects for class (ac/ic), function (af/if), and docstring (ad/id)
" also adds g: normal mode map to specify context of cursor location
" Plug 'jeetsukumaran/vim-pythonsense'
" IDE level vim/go integration
Plug 'fatih/vim-go', { 'for': 'go' }
" Comprehensive Rust plugin
Plug 'rust-lang/rust.vim'
" fish shell syntax etc
Plug 'dag/vim-fish', { 'for': 'fish' }
" dockerfile support
Plug 'ekalinin/Dockerfile.vim', { 'for': 'dockerfile' }
" mako support
Plug 'sophacles/vim-bundle-mako'
" elm support
Plug 'Zaptic/elm-vim'
" color scheme
" Plug 'TroyFletcher/vim-colors-synthwave'
" Plug 'shaunsingh/moonlight.nvim'
Plug 'marko-cerovac/material.nvim'
" Plug 'rafamadriz/neon'
" Plug 'ful1e5/onedark.nvim'
" Plug 'yashguptaz/calvera-dark.nvim'
" Plug 'folke/tokyonight.nvim'
" Plug 'seanjbl/tonight.nvim'
Plug 'wuelnerdotexe/vim-enfocado'
" Async lint runner
Plug 'w0rp/ale'
" adds gS and gJ to syntactically aware split/join constructs
Plug 'AndrewRadev/splitjoin.vim'
" :s live feedback
Plug 'osyo-manga/vim-over'
" fzf fuzzy finder and wrapper
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'hynek/vim-python-pep8-indent'
" Plug 'bwells/vim-named-sessions'
" Plug 'bwells/simplysublime'
Plug 'FooSoft/vim-argwrap'
" defines a sort motion
Plug 'christoomey/vim-sort-motion'
Plug 'machakann/vim-highlightedyank'
" improves terminal support - adds insert mode cursor
Plug 'wincent/terminus'
" integrated test running
Plug 'janko-m/vim-test'
Plug 'stevearc/vim-arduino'
" quickfix list helpers
Plug 'romainl/vim-qf'
" base64 encoding
" <leader>btoa and <leader>atob in visual
Plug 'christianrondeau/vim-base64'
if has('nvim')
" Treesitter configs and parsers
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
" LSP configs and servers
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
" Telescope
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
Plug 'kyazdani42/nvim-web-devicons'
" alternative file finder to Telescope.
" Plug 'camspiers/snap'
" completion and snippets
" Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
" Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'onsails/lspkind-nvim'
" build system, still not mapped
Plug 'pianocomposer321/yabs.nvim'
Plug 'numToStr/Comment.nvim'
" colorscheme switcher
Plug 'metalelf0/witch-nvim'
else
" gcc to toggle comment current line
" gc to toggle comment selected line(s)
Plug 'tomtom/tcomment_vim'
endif
" Add plugins to &runtimepath
call plug#end()
" tell vim that your terminal supports 256 colors
let base16colorspace=256
" set t_8f=^[[38;2;%lu;%lu;%lum
" set t_8b=^[[48;2;%lu;%lu;%lum
set t_Co=256
"""""""""""""""""""""""
" PLUGIN CONFIGURATION
"""""""""""""""""""""""
if has('nvim')
" configure treesitter
" installs all parsers and enables treesitter for all of those
lua << EOF
--
-- TreeSitter
--
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
highlight = {
enable = true, -- false will disable the whole extension
disable = {}, -- list of language that will be disabled
},
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
-- ["ac"] = "@class.outer",
-- ["ic"] = "@class.inner",
["ac"] = "@comment.outer",
["ic"] = "@comment.outer",
["al"] = "@loop.outer",
["il"] = "@loop.inner",
-- Or you can define your own textobjects like this
-- ["iF"] = {
-- python = "(function_definition) @function",
-- cpp = "(function_definition) @function",
-- c = "(function_definition) @function",
-- java = "(method_declaration) @function",
-- },
},
},
lsp_interop = {
enable = true,
border = 'none',
peek_definition_code = {
["df"] = "@function.outer",
["dF"] = "@class.outer",
},
},
-- move = {
-- enable = true,
-- set_jumps = true, -- whether to set jumps in the jumplist
-- goto_next_start = {
-- ["]m"] = "@function.outer",
-- ["]]"] = "@class.outer",
-- },
-- goto_next_end = {
-- ["]M"] = "@function.outer",
-- ["]["] = "@class.outer",
-- },
-- goto_previous_start = {
-- ["[m"] = "@function.outer",
-- ["[["] = "@class.outer",
-- },
-- goto_previous_end = {
-- ["[M"] = "@function.outer",
-- ["[]"] = "@class.outer",
-- },
-- },
},
}
--
-- LSP
--
local nvim_lsp = require('lspconfig')
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[e', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']e', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
end
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.on_server_ready(function(server)
local opts = {}
-- disable python diagnostics for now
if server.name == "pylsp" then
opts.handlers = {
["textDocument/publishDiagnostics"] = function() end
}
end
if server.name == 'elmls' then
opts['capabilities'] = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
end
opts.on_attach = on_attach
nvim_lsp[server.name].setup(opts)
end)
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
signs = {
severity_limit = "Hint",
},
virtual_text = {
severity_limit = "Warning",
},
}
)
--
-- Telescope
--
local actions = require('telescope.actions')
require('telescope').setup{
defaults = {
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
n = { },
},
},
extensions = {
fzf = {
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
}
}
}
require('telescope').load_extension('fzf')
require("yabs"):setup {
languages = { -- List of languages in vim `filetype` format
elm = {
default_task = "build_and_run",
tasks = {
build = {
command = "cd elm; find src/Entry -name '*.elm' | xargs elm make --output ../portal/public/scripts/elm.js --debug",
output = "echo",
}
}
}
}
}
vim.api.nvim_set_keymap('n', '<Leader>y', '<cmd>Telescope yabs tasks<cr>', {noremap = true})
-- colorscheme material
vim.g.material_style = "deep ocean"
vim.g.material_terminal_italics = false
vim.g.material_italic_comments = false
vim.g.material_italic_keywords = false
vim.g.material_italic_functions = false
vim.g.material_italic_variables = false
EOF
endif
""" netrw
let g:netrw_liststyle = 3
let g:netrw_altv = 1
" TODO: idea: add command for jumping up or down when you meant the opposite
" -> 10j, shit i meant to 10k. rather than have to hit 20k, hit K and it
" calculates that your last jump was 10 down, so go up 20.
""" vim-named-sessions
" don't save hidden buffers
" set sessionoptions-=buffers
set sessionoptions-=options
""" nerdtree
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let g:NERDTreeRespectWildIgnore = 1
""" vim-go
" use goimports instead of gofmt on save
let g:go_fmt_command = "goimports"
""" cutlass.vim
nnoremap m d
xnoremap m d
nnoremap gm m
nnoremap mm dd
nnoremap M D
""" yoink.vim
let g:yoinkIncludeDeleteOperations = 1
nmap <c-p> <plug>(YoinkPostPasteSwapBack)
nmap <c-n> <plug>(YoinkPostPasteSwapForward)
nmap p <plug>(YoinkPaste_p)
nmap P <plug>(YoinkPaste_P)
" Also replace the default gp with yoink paste so we can toggle paste in this case too
nmap gp <plug>(YoinkPaste_gp)
nmap gP <plug>(YoinkPaste_gP)
nnoremap Y y$
""" vim-bbye
" alias Bdelete to Bclose
command! -bang -complete=buffer -nargs=? Bclose Bdelete<bang> <args>
" map 'bc' to 'Bc' for ease of typing
cnoreabbrev <expr> bc ((getcmdtype() is# ':' && getcmdline() is# 'bc')?('Bc'):('bc'))
""" lightline.vim
" disable vim's own mode indicator
set noshowmode
" uses menlo for powerline from
" https://gist.github.com/justinmayer/7537418#file-menlo-for-powerline-zip
let g:lightline = {
\ 'colorscheme': 'nord',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive' ],
\ [ 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'filetype', 'fileformat', 'fileencoding' ] ]
\ },
\ 'inactive': {
\ 'left': [ [ 'filename' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename'
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"[+]":&modifiable?"":"-"}',
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
function! LightLineFugitive()
if exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? ' '._ : ''
endif
return ''
endfunction
function! LightLineFilename()
return expand('%')
endfunction
set statusline=
set statusline+=%#warningmsg#
set statusline+=%*
""" vim-gitgutter
let g:gitgutter_sign_added = '✚'
let g:gitgutter_sign_modified = '➜'
let g:gitgutter_sign_removed = '✘'
""" tcomment_vim
" change the comment character for .ini files
if exists("tcomment")
call tcomment#type#Define('dosini', '#%s')
endif
""" Comment.nvim
if has('nvim')
lua << EOF
require('Comment').setup()
local ft = require('Comment.ft')
ft.text = '# %s'
EOF
endif
""" vim-wordmotion
let g:wordmotion_prefix = "<leader>"
" override the default 'b' mapping to avoid conflicting
" with <leader>b to open FZF buffer search
let g:wordmotion_mappings = { 'b': '<M-b>' }
""" ale
let g:ale_linters = {
\ 'python': ['flake8', 'pylint'],
\ 'javascript': ['eslint'],
\ 'elm': []
\}
" let g:ale_fixers = {
" \ 'python': ['black', 'isort']
" \}
" let g:ale_fix_on_save = 1
let g:ale_python_pylint_options = '--rcfile ~/.pylintrc'
let g:ale_python_pylint_use_global = 0
nmap <silent> [E <Plug>(ale_previous_wrap)
nmap <silent> ]E <Plug>(ale_next_wrap)
""" vim-sneak
" add easymotion like arbitrary key for global movement to sneak
" let g:sneak#streak = 1
" let g:sneak#s_next = 1
" let g:sneak#absolute_dir = 1
""" vim-argwrap
nnoremap <silent> <leader>a :ArgWrap<CR>
""" ack.vim
if executable('rg')
let g:ackprg = 'rg --vimgrep'
elseif executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
function! GetFileType()
" map vim filetype values to those accepted by rg's -t option
let l:type_remaps = {
\ 'javascript': 'js',
\ 'mako': 'html',
\ 'python': 'py',
\}
" fetch filetype overrides, defaulting to vim's filetype value
return get(l:type_remaps, &filetype, &filetype)
endfunction
" <left> leaves the cursor position in between the quotes
nnoremap <leader>/ :Ack!<space>-F<space>""<left>
nnoremap <expr> <leader>l ':Ack! -F -t ' . GetFileType() . ' ""<left>'
" xnoremap <leader>/ y:Ack -F "<c-r>""
xnoremap <leader>/ :<c-u>Ack -F "<c-r>=<SID>GetVisualSelection()<cr>"
function! s:GetVisualSelection()
try
let a_save = @a
" select the last visual selection again
" and then yank it to register a
normal! gv"ay
return @a
finally
let @a = a_save
endtry
endfunction
""" lightspeed
lua << EOF
require'lightspeed'.setup {
grey_out_search_area = true
}
EOF
""" vim-sort-motion
let g:sort_motion_flags = "ui"
""" fzf.vim
" set the default FZF default feed command here because it's
" not set in zsh, which is the shell vim actually uses.
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files'
elseif executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag -l -g ""'
endif
" switch to a different panel if running fzf from within nerdtree
if has('nvim')
" nnoremap <leader>fb <cmd>Telescope file_browser<cr>
nnoremap <leader>gs <cmd>Telescope grep_string<cr>
nnoremap <leader>lg <cmd>Telescope live_grep<cr>
nnoremap <leader>/ <cmd>Telescope live_grep<cr>
nnoremap <leader>ts <cmd>Telescope treesitter<cr>
nnoremap <Leader>f <cmd>Telescope find_files<cr>
nnoremap <Leader>b <cmd>Telescope buffers<cr>
nnoremap <Leader>t <cmd>Telescope tags<cr>
nnoremap <Leader>q <cmd>Telescope quickfix<cr>
" imap c-/ to see picker actions help
" map ? to see picker actions help
else
nnoremap <silent> <expr> <Leader>f (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":FZF\<cr>"
nnoremap <Leader>b :Buffers<cr>
nnoremap <Leader>t :Tags<cr>
endif
" nnoremap <silent> <expr> <Leader>f (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":FZF\<cr>"
" nnoremap <Leader>b :Buffers<cr>
" nnoremap <Leader>t :Tags<cr>
" jump to existing buffers rather than open a new one
let g:fzf_buffers_jump = 1
let g:fzf_layout = {
\ 'down': '~25%',
\}
" Using floating windows of Neovim to start fzf
if has('nvim')
function! FloatingFZF(width, height, border_highlight)
function! s:create_float(hl, opts)
let buf = nvim_create_buf(v:false, v:true)
let opts = extend({'relative': 'editor', 'style': 'minimal'}, a:opts)
let win = nvim_open_win(buf, v:true, opts)
call setwinvar(win, '&winhighlight', 'NormalFloat:'.a:hl)
call setwinvar(win, '&colorcolumn', '')
return buf
endfunction
" Size and position
let width = float2nr(&columns * a:width)
let height = float2nr(&lines * a:height)
let row = float2nr((&lines - height) / 1.5)
let col = float2nr((&columns - width) / 2)
" Border
let top = '╭' . repeat('─', width - 2) . '╮'
let mid = '│' . repeat(' ', width - 2) . '│'
let bot = '╰' . repeat('─', width - 2) . '╯'
let border = [top] + repeat([mid], height - 2) + [bot]
" Draw frame
let s:frame = s:create_float(a:border_highlight, {'row': row, 'col': col, 'width': width, 'height': height})
call nvim_buf_set_lines(s:frame, 0, -1, v:true, border)
" Draw viewport
call s:create_float('Normal', {'row': row + 1, 'col': col + 2, 'width': width - 4, 'height': height - 2})
autocmd BufWipeout <buffer> execute 'bwipeout' s:frame
endfunction
let g:fzf_layout = { 'window': 'call FloatingFZF(0.93, 0.5, "Comment")' }
endif
""" vim-highlightedyank
" number of miliseconds to highlight the yank
let g:highlightedyank_highlight_duration = 200
" update the highlight to a color that does not obscure the cursor
" highlight HighlightedyankRegion guibg=#af005f cterm=125
""" vim-qf
let g:qf_shorten_path = 0
""" coq
" set completeopt=menuone,noselect,noinsert
" set shortmess+=c
"
" let g:coq_settings = { 'auto_start': v:true }
""" nvim-cmp
set completeopt=menu,menuone,noselect
lua << EOF
-- Setup nvim-cmp.
local lspkind = require'lspkind'
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
mapping = {
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = "buffer", keyword_length = 5 },
}),
-- ganked from tj's settings
formatting = {
format = lspkind.cmp_format {
with_text = true,
menu = {
buffer = "[buf]",
nvim_lsp = "[LSP]",
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
gh_issues = "[issues]",
tn = "[TabNine]",
},
},
},
experimental = {
-- I like the new menu better! Nice work hrsh7th
native_menu = false,
-- Let's play with this for a day or two
ghost_text = true,
},
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
-- require('lspconfig')['elmls'].setup {
-- capabilities = capabilities
-- }
EOF
""""""""""""""""
" IT'S NOT 1970
""""""""""""""""
" " tell vim that your terminal supports 256 colors
" let base16colorspace=256
" " set t_8f=^[[38;2;%lu;%lu;%lum
" " set t_8b=^[[48;2;%lu;%lu;%lum
" set t_Co=256
set ttyfast
" enable the mouse
if has('mouse')
set mouse=a
if !has('nvim')
set ttymouse=xterm2
endif
endif
"""""""""""""""""""""""""
" BASE VIM CONFIGURATION
"""""""""""""""""""""""""
if (has('termguicolors'))
set termguicolors
endif
if has('nvim')
" ctrl-h == backspace in basic shell.
" override this in nvim's case to get correct split navigation back
" nmap <BS> <C-W>h
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>
" map esc to switch-to-normal-mode in a terminal
tnoremap <Esc> <C-\><C-n>
endif
if exists('&guifont')
set guifont=Menlo\ Regular\ for\ Powerline:h11
endif
" turn on line numbers
set number
" turn on relative line numbers
set relativenumber
" set ruler at 81 chars
set colorcolumn=81,101
" highlight the line the cursor is on
set cursorline
" only enable cursorline in the active buffer
" TODO: add relativenumber to this, but make it smart enough to not set
" relativenumber on help windows
augroup CursorLine
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
" enable lazyredraw to not slaughter performance
set lazyredraw
" open new splits to the right or below
" like a non sociopath
set splitbelow
set splitright
" allows you to have multiple buffers open
set hidden
" lines of code will not wrap to the next line
set nowrap
" copy the indentation of the previous line
" if the auto indent doesn't know what to do
" set autoindent
" set copyindent
" highlight matching braces/tags
set showmatch
" ignore case when searching
set ignorecase
" ... unless there's a capital letter in the query
set smartcase
" indent to correct locatin with tab
set smarttab
" highlight search matches
set hlsearch
" search while you enter they query, not after
set incsearch
" let vim set the title of the terminal window
set title
" use a visual indiator instead of a beep
set visualbell
" change the default register to the system clipboard
set clipboard^=unnamed
" enable syntax highlighting
syntax enable
" colors synthwave
" hi ColorColumn guifg=NONE guibg=#536991 guisp=NONE ctermfg=NONE ctermbg=60 cterm=NONE
" hi Function guifg=#ff00bb guibg=NONE guisp=NONE gui=NONE ctermfg=199 ctermbg=NONE cterm=bold
" hi String guifg=#dd00ff guibg=#181615 guisp=#000000 gui=NONE ctermfg=165 ctermbg=NONE cterm=NONE
" hi Comment guifg=#9c38bd guibg=#181615 guisp=NONE gui=italic ctermfg=5 ctermbg=0 cterm=NONE
" hi Exception guifg=#bd0065 guibg=#181615 guisp=#000000 gui=bold ctermfg=5 ctermbg=NONE cterm=bold
" hi Normal guifg=#f9fcfc guibg=#181615 guisp=#181615 gui=NONE ctermfg=15 ctermbg=234 cterm=NONE
" hi SignColumn guifg=#f9fcfc guibg=#181615 guisp=#181615 gui=NONE ctermfg=15 ctermbg=234 cterm=NONE
" hi ColorColumn guifg=NONE guibg=#db93c8 guisp=#db93c8 ctermfg=235 ctermbg=248 cterm=NONE
" hi ColorColumn guifg=NONE guibg=#6cddf1 guisp=#db93c8 ctermfg=235 ctermbg=248 cterm=NONE
" hi ColorColumn guifg=NONE guibg=#bd0065 guisp=NONE ctermfg=NONE ctermbg=248 cterm=NONE
" original material dark CursorColumn
" highlight cterm=underline guibg=#1A1C25
" highlight CursorLine cterm=underline guibg=#30323A
" highlight CursorLine cterm=underline guibg=#262830
highlight CursorLine cterm=underline guibg=#1B1D25
" 0F111A is normal material dark background
" 262830 bump lighter
let g:enfocado_style = "neon"
let s:mycolors = ['material', 'enfocado']
nnoremap <leader>c :call NextColor(1)<CR>
colorscheme material
" disable fucking folding
augroup fuck_folding
autocmd!
autocmd BufEnter * set nofoldenable
augroup END
" use rg for grep
if executable('rg')
set grepprg=rg\ --vimgrep
endif
set timeoutlen=500
"""""""
" MAPS
"""""""
" Skip any internal matching pairs and jump to the match of the line end match
" works well, but the delay in single % use is too annoying
nnoremap <leader>% $%
" vim-tmux-navigator adds ctrl-hjkl and / for pane navigation
" buffer navigation
" I'm basically never using these. Find a better use for tab.
nnoremap <tab> :bnext<cr>
nnoremap <s-tab> :bprev<cr>
" jump to mru buffer
nnoremap <leader><tab> :b#<cr>
" clear highlight with <esc><esc> after a search
nnoremap <esc><esc> :noh<return><esc>
" disable arrow keys in normal mode
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" if i hit c-j/k in insert mode dump out and do what i wanted
inoremap <C-j> <esc><c-w><c-j>