-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.vimrc
1704 lines (1500 loc) · 58.3 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
set nocompatible " be iMproved, required
filetype off " required
" Vundle Stuff
if has("win32") || has("win16")
call plug#begin('$HOME/vimfiles/bundle/')
else
call plug#begin('~/.vim/bundle')
endif
" Set mapleader before plugin loads
nnoremap <SPACE> <Nop>
let mapleader=" "
let maplocalleader=" "
" Optional plugins
let js_dev_enabled = 1
" Vim Internal Plugins
if !has('nvim')
packadd matchit
endif
" Python paths
if has('nvim')
if has("win32") || has("win16")
let g:python3_host_prog = 'C:\Users\leandros\AppData\Local\Programs\Python\Python310\python.exe'
else
let g:python3_host_prog = '/usr/local/bin/python3'
endif
endif
" Ugly workaround until vim fixes
if has('python3')
silent! python3 1
endif
" Visual Plugins
if has('nvim') && !empty($NVIM_GUI)
Plug 'frankier/neovim-colors-solarized-truecolor-only'
Plug 'equalsraf/neovim-gui-shim'
elseif has('nvim')
Plug 'ishan9299/nvim-solarized-lua'
" I prefer the nvim-solarized-lua
" Plug 'lifepillar/vim-solarized8'
else
Plug 'altercation/vim-colors-solarized'
endif
" Absolute Must Haves!
Plug 'tpope/vim-commentary'
Plug 'terryma/vim-multiple-cursors'
Plug 'Konfekt/FastFold'
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'mhinz/vim-grepper'
Plug 'axelf4/vim-strip-trailing-whitespace'
" Interferes with telescope.
" Plug 'thirtythreeforty/lessspace.vim'
Plug 'maxbrunsfeld/vim-yankstack'
Plug 'scrooloose/nerdtree'
Plug 'ggandor/lightspeed.nvim'
" General
Plug 'SirVer/ultisnips'
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/vim-peekaboo'
" Required for 'EnhancedJumps'
Plug 'vim-scripts/ingo-library'
Plug 'vim-scripts/EnhancedJumps'
" My own plugins
Plug 'leandros/vim-misc'
" My forks
Plug 'leandros/QFEnter'
Plug 'leandros/vim-bufkill'
" Rust
if has('nvim')
" Basically all for LSP support.
Plug 'neovim/nvim-lspconfig' " Collection of common configurations for the Nvim LSP client
Plug 'williamboman/nvim-lsp-installer'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'nvim-lua/plenary.nvim' " Lua library
Plug 'hrsh7th/nvim-cmp' " Completion framework
Plug 'hrsh7th/cmp-nvim-lsp' " LSP completion source for nvim-cmp
Plug 'hrsh7th/cmp-vsnip' " Snippet completion source for nvim-cmp
Plug 'hrsh7th/cmp-path' " Completion for paths
Plug 'hrsh7th/cmp-buffer' " Completion from buffer
Plug 'hrsh7th/vim-vsnip' " Snippet engine
Plug 'nvim-telescope/telescope.nvim'
" Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
Plug 'leandros/telescope-fzf-native.nvim', { 'do': 'make', 'branch': 'feature/windows_build_support' }
Plug 'folke/lsp-colors.nvim' " Highlight groups for trouble.nvim
Plug 'folke/trouble.nvim' " Pretty diagnostics
Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
Plug 'ray-x/navigator.lua'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'lewis6991/gitsigns.nvim'
Plug 'simrat39/rust-tools.nvim'
" Lightline
Plug 'nvim-lualine/lualine.nvim'
" Debugging
" Plug 'mfussenegger/nvim-dap' " debug adapter for debugging
" Plug 'theHamsta/nvim-dap-virtual-text' " virtual text during debugging
" Plug 'rcarriga/nvim-dap-ui' " for nvim-dap
endif
" Prettier
Plug 'Chiel92/vim-autoformat', { 'for': ['gn', 'jbuild', 'opam', 'python'] }
Plug 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'javascript.jsx', 'typescript', 'typescript.tsx', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
Plug 'cofyc/vim-uncrustify', { 'for': ['cpp', 'c', 'cs', 'objc', 'objcpp'] }
" Syntax Plugins
Plug 'dummyunit/vim-fastbuild', { 'for': ['fastbuild'] }
Plug 'wlangstroth/vim-racket', { 'for': ['racket'] }
Plug 'luochen1990/rainbow', { 'for': ['scheme', 'lisp', 'racket'] }
Plug 'leandros/hlsl.vim', { 'for': ['hlsl'] }
Plug 'leandros/vim-gn', { 'for': ['gn'] }
Plug 'aexpl/vim-aexpl', { 'for': ['aexpl'] }
Plug 'jparise/vim-graphql', { 'for': ['graphql'] }
Plug 'qnighy/lalrpop.vim', { 'for': ['lalrpop'] }
Plug 'rust-lang/rust.vim', { 'for': ['rust'] }
Plug 'cespare/vim-toml', { 'for': ['toml'], 'branch': 'main' }
if js_dev_enabled
Plug 'leafgarland/typescript-vim'
Plug 'pangloss/vim-javascript'
Plug 'elzr/vim-json'
endif
call plug#end()
" required for remapping Y to y$
" has to come after plug#end()
if has_key(g:plugs, 'vim-yankstack')
call yankstack#setup()
endif
" =============================================================================
" NEOVIM
" =============================================================================
if has('nvim')
" Set completeopt to have a better completion experience
" :help completeopt
" menuone: popup even when there's only one match
" noinsert: Do not insert text until a selection is made
" noselect: Do not select, force user to select one from the menu
set completeopt=menuone,noinsert,noselect
" Avoid showing extra messages when using completion
set shortmess+=c
" =============================================================================
" LSP INSTALLER
" =============================================================================
lua << EOF
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.settings({
ui = {
icons = {
server_installed = "✓",
server_pending = "➜",
server_uninstalled = "✗"
}
}
})
lsp_installer.on_server_ready(function(server)
local opts = {}
-- Configure LSP through rust-tools.nvim plugin.
-- rust-tools will configure and enable certain LSP features for us.
-- See https://github.com/simrat39/rust-tools.nvim#configuration
if server.name == "rust_analyzer" then
local rust_opts = {
tools = { -- rust-tools options
autoSetHints = true,
hover_with_actions = false,
inlay_hints = {
-- Only show inlay hints for the current line
only_current_line = false,
-- wheter to show parameter hints with the inlay hints or not
show_parameter_hints = true,
-- prefix for parameter hints
parameter_hints_prefix = "<- ",
-- prefix for all the other hints (type, chaining)
other_hints_prefix = "=> ",
-- whether to align to the length of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- The color of the hints
highlight = "Comment",
},
runnables = {
use_telescope = true,
},
debuggables = {
use_telescope = true,
},
},
server = vim.tbl_deep_extend("force", server:get_default_options(), opts, {
settings = {
["rust_analyzer"] = {
checkOnSave = {
command = "clippy"
}
}
}
}),
}
require("rust-tools").setup(rust_opts)
server:attach_buffers()
else
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end
end)
EOF
command! RustSetInlayHints lua require"rust-tools.inlay_hints".set_inlay_hints()
command! RustDisableInlayHints lua require"rust-tools.inlay_hints".disable_inlay_hints()
command! RustToggleInlayHints lua require"rust-tools.inlay_hints".toggle_inlay_hints()
command! RustReloadWorkspace lua require"rust-tools/workspace_refresh".reload_workspace()
augroup RustInlayHints
autocmd!
autocmd BufEnter,BufWinEnter,TabEnter,BufWritePost *.rs lua require"rust-tools.inlay_hints".set_inlay_hints()
augroup END
" =============================================================================
" Completion
" =============================================================================
" See https://github.com/hrsh7th/nvim-cmp#basic-configuration
lua <<EOF
local cmp = require 'cmp'
cmp.setup({
documentation = {
border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' },
},
-- Enable LSP snippets
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-r>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
-- Add tab support
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.select_next_item(),
['<C-,>'] = cmp.mapping.scroll_docs(-4),
['<C-.>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-j>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
},
-- Installed sources
sources = {
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'path' },
{ name = 'buffer' },
},
})
EOF
" =============================================================================
" TROUBLE
" =============================================================================
lua << EOF
require("trouble").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
EOF
" =============================================================================
" LSPCOLORS
" =============================================================================
lua << EOF
require("lsp-colors").setup({
Error = "#db4b4b",
Warning = "#e0af68",
Information = "#0db9d7",
Hint = "#10B981"
})
EOF
" =============================================================================
" LUALINE
" =============================================================================
lua << EOF
local colors = {
base03 = '#002b36',
base02 = '#073642',
base01 = '#586e75',
base00 = '#657b83',
base0 = '#839496',
base1 = '#93a1a1',
base2 = '#eee8d5',
base3 = '#fdf6e3',
yellow = '#b58900',
orange = '#cb4b16',
red = '#dc322f',
magenta = '#d33682',
violet = '#6c71c4',
blue = '#268bd2',
cyan = '#2aa198',
green = '#859900',
}
local custom_solarized = {
normal = {
a = { fg = colors.base03, bg = colors.blue, gui = 'bold' },
b = { fg = colors.base0, bg = colors.base03 },
c = { fg = colors.base0, bg = colors.base02 },
},
insert = { a = { fg = colors.base03, bg = colors.green, gui = 'bold' } },
visual = { a = { fg = colors.base03, bg = colors.magenta, gui = 'bold' } },
replace = { a = { fg = colors.base03, bg = colors.red, gui = 'bold' } },
inactive = {
a = { fg = colors.base0, bg = colors.base02, gui = 'bold' },
b = { fg = colors.base03, bg = colors.base00 },
c = { fg = colors.base01, bg = colors.base02 },
},
}
require'lualine'.setup {
options = {
icons_enabled = false,
theme = custom_solarized,
component_separators = '│',
section_separators = '',
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_b = {'branch', {'diagnostics', sources={'nvim_diagnostic', 'coc'}}},
lualine_c = {{'filename', file_status = true, path = 1}},
},
}
EOF
" =============================================================================
" Navigator
" =============================================================================
lua <<EOF
require'navigator'.setup({
border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"},
transparency = nil,
default_mapping = false,
keymaps = {
-- Keymaps defined below:
-- {key = "<c-k>", func = "signature_help()"},
-- {key = "<c-]>", func = "require('navigator.definition').definition()"},
-- {key = "gd", func = "require('navigator.definition').definition_preview()"},
-- {key = "K", func = "hover({ popup_opts = { border = single, max_width = 80 }})"},
-- {key = "<Leader>re", func = "rename()"},
-- {key = "<Leader>rn", func = "require('navigator.rename').rename()"},
-- --{key = "<Leader>gi", func = "incoming_calls()"},
-- --{key = "<Leader>go", func = "outgoing_calls()"},
-- {key = "<Leader>k", func = "require('navigator.diagnostics').show_diagnostics()"},
-- =========
-- Enabled in telescope.nvim:
-- =========
--{key = "gr", func = "require('navigator.reference').reference()"},
--{key = "<Leader>ca", mode = "n", func = "require('navigator.codeAction').code_action()"},
--{key = "<Leader>cA", mode = "v", func = "range_code_action()"},
-- =========
-- Unused:
-- =========
--{mode = "i", key = "<leader>s", func = "signature_help()"},
--{key = "g0", func = "require('navigator.symbols').document_symbols()"},
--{key = "gW", func = "workspace_symbol()"},
--{key = "gD", func = "declaration({ border = 'rounded', max_width = 80 })"},
--{key = "gT", func = "require('navigator.treesitter').buf_ts()"},
--{key = "<Leader>gT", func = "require('navigator.treesitter').bufs_ts()"},
--{key = "gi", func = "implementation()"},
--{key = "<Leader>d", func = "type_definition()"},
--{key = "gG", func = "require('navigator.diagnostics').show_buf_diagnostics()"},
--{key = "<Leader>dt", func = "require('navigator.diagnostics').toggle_diagnostics()"},
--{key = "]d", func = "diagnostic.goto_next({ border = 'rounded', max_width = 80})"},
--{key = "[d", func = "diagnostic.goto_prev({ border = 'rounded', max_width = 80})"},
--{key = "]r", func = "require('navigator.treesitter').goto_next_usage()"},
--{key = "[r", func = "require('navigator.treesitter').goto_previous_usage()"},
--{key = "<C-LeftMouse>", func = "definition()"},
--{key = "g<LeftMouse>", func = "implementation()"},
--{key = "<Leader>k", func = "require('navigator.dochighlight').hi_symbol()"},
--{key = '<Space>wa', func = 'add_workspace_folder()'},
--{key = '<Space>wr', func = 'remove_workspace_folder()'},
--{key = '<Space>ff', func = 'formatting()', mode='n'},
--{key = '<Space>ff', func = 'range_formatting()', mode='v'},
--{key = '<Space>wl', func = 'print(vim.inspect(vim.lsp.buf.list_workspace_folders()))'},
--{key = "<Space>la", mode = "n", func = "require('navigator.codelens').run_action()"},
},
icons = {
icons = true, -- set to false to use system default (if you using a terminal does not have nerd/icon)
-- Code action
code_action_icon = '⚐ ',
-- code lens
code_lens_action_icon = '',
-- Diagnostics
diagnostic_head = ' ⚠ ',
diagnostic_err = 'E',
diagnostic_warn = 'W',
diagnostic_info = 'I',
diagnostic_hint = 'H',
diagnostic_head_severity_1 = ' ⚠ ',
diagnostic_head_severity_2 = ' ⚠ ',
diagnostic_head_severity_3 = ' ⚠ ',
diagnostic_head_description = ' ⚠ ',
diagnostic_virtual_text = '▷',
diagnostic_file = ' ⚠ ',
-- Values
value_changed = '',
value_definition = '',
-- Treesitter
match_kinds = {
['function'] = 'f',
var = 'v',
method = 'm',
parameter = 'p',
associated = '',
namespace = 'n',
type = 't',
field = '',
},
treesitter_defult = '',
},
lsp_installer = false,
lsp = {
code_action = {enable = true, sign = true, sign_priority = 40, virtual_text = false},
code_lens_action = {enable = true, sign = true, sign_priority = 40, virtual_text = false},
format_on_save = false,
},
})
EOF
nnoremap <silent><c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent><c-]> <cmd>lua require('navigator.definition').definition()<CR>
nnoremap <silent>gd <cmd>lua require('navigator.definition').definition_preview()<CR>
nnoremap <silent>K <cmd>lua vim.lsp.buf.hover({ popup_opts = { border = single, max_width = 80 }})<CR>
nnoremap <silent><Leader>re <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent><Leader>rn <cmd>lua require('navigator.rename').rename()<CR>
nnoremap <silent><Leader>k <cmd>lua require('navigator.diagnostics').show_diagnostics()<CR>
" =============================================================================
" GitSigns
" =============================================================================
lua << EOF
require('gitsigns').setup({
keymaps = {
noremap = true,
['n <leader>hs'] = '<cmd>Gitsigns stage_hunk<CR>',
['v <leader>hs'] = ':Gitsigns stage_hunk<CR>',
['n <leader>hu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
['n <leader>hr'] = '<cmd>Gitsigns reset_hunk<CR>',
['v <leader>hr'] = ':Gitsigns reset_hunk<CR>',
['n <leader>hR'] = '<cmd>Gitsigns reset_buffer<CR>',
['n <leader>hp'] = '<cmd>Gitsigns preview_hunk<CR>',
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
['n <leader>hS'] = '<cmd>Gitsigns stage_buffer<CR>',
['n <leader>hU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
},
})
EOF
lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = {'rust', 'json', 'javascript', 'typescript', 'tsx', 'vim'},
}
EOF
lua <<EOF
require'lightspeed'.setup {
highlight_unique_chars = true,
}
EOF
" 2-character search (x/x) (Normal)
nmap <silent>t <Plug>Lightspeed_s
nmap <silent>T <Plug>Lightspeed_S
nmap <silent>x <Plug>Lightspeed_x
nmap <silent>X <Plug>Lightspeed_X
" 2-character search (x/x) (Visual)
vmap <silent>t <Plug>Lightspeed_s
vmap <silent>T <Plug>Lightspeed_S
vmap <silent>x <Plug>Lightspeed_x
vmap <silent>X <Plug>Lightspeed_X
" 1-character search (f/t) (Normal)
nmap <silent>e <Plug>Lightspeed_f
nmap <silent>E <Plug>Lightspeed_F
nmap <silent>ä <Plug>Lightspeed_t
nmap <silent>Ä <Plug>Lightspeed_T
" 1-character search (f/t) (Visual)
vmap <silent>e <Plug>Lightspeed_f
vmap <silent>E <Plug>Lightspeed_F
vmap <silent>Ä <Plug>Lightspeed_t
vmap <silent>Ä <Plug>Lightspeed_T
" Code navigation shortcuts
nnoremap <silent> <leader>d <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> <leader>i <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <leader>y <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> <leader>r <cmd>lua vim.lsp.buf.references()<CR>
" nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
" nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
" nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
" nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
" nnoremap <silent> ge <cmd>lua vim.lsp.buf.code_action()<CR>
" nnoremap <silent> gh :Lspsaga lsp_finder<CR>
" nnoremap <silent> ge :Lspsaga code_action<CR>
" nnoremap <silent> K :Lspsaga hover_doc<CR>
" nnoremap <silent> <S-h> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>
" nnoremap <silent> <S-l> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>
" nnoremap <silent> <leader>s :Lspsaga signature_help<CR>
" nnoremap <silent> <leader>rn :Lspsaga rename<CR>
" nnoremap <silent> gd :Lspsaga preview_definition<CR>
" nnoremap <silent> <leader>cd :Lspsaga show_line_diagnostics<CR>
" nnoremap <silent> [e :Lspsaga diagnostic_jump_next<CR>
" nnoremap <silent> ]e :Lspsaga diagnostic_jump_prev<CR>
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("nvim-0.5.0") || has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Show diagnostic popup on cursor hold
" autocmd CursorHold * lua require'lspsaga.diagnostic'.show_line_diagnostics()
" autocmd CursorHold * lua require('navigator.diagnostics').show_diagnostics()
" Goto previous/next diagnostic warning/error
nnoremap <silent> gr <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
nnoremap <silent> gn <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
endif
" =============================================================================
" Language / Shell
" =============================================================================
set langmenu=en_US.UTF-8
let $LANG='en_US'
" Set the default shell
if has("win32") || has("win16")
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set shell=cmd.exe
set shellcmdflag=/C
else
set shell=$SHELL
endif
" =============================================================================
" General
" =============================================================================
set fileencoding=utf-8 " Set the encoding written to file
set termencoding=utf-8 " Set the default encodings just in case $LANG isn't set
set encoding=utf-8 " Set the default encodings just in case $LANG isn't set
set cursorline " Hightlight current selected line.
set ttyfast " Set that we have a fast terminal
set emoji " enable emoji's on Vim8
set clipboard+=unnamed " enabled system clipboard
syntax enable
set hidden " Hide buffer, instead of closing it.
set number " Always show line numbers.
set hlsearch " Hightlight found searches.
set incsearch " Show matched searches as you type.
set ignorecase " Ignore case when searching.
set smartcase " Ignore case if search pattern is all lowercase, case-sensitive otherwise.
set nowrapscan " Do not wrap when searching
set history=1000 " Larger command history.
set undolevels=1000 " Undo ALL the changes.
set visualbell " Don't beep.
set noerrorbells " Don't beep.
set nobackup " Disable backup. set noswapfile can disable the .swp file.
set nowritebackup
set noswapfile
" Indentation is 4 spaces, and not a tab
set tabstop=4 " A tab is 4 spaces.
set autoindent " Autoindent.
set copyindent " Copy the previous indent on autoindenting.
set shiftwidth=4 " Number of spaces used for autoindent.
set expandtab " Expand <Tab> into spaces
set smarttab " Insert 'tabs' on start of line, according to shiftwidth instead of tabstop.
set scrolloff=3 " 3 lines of buffer above and below the cursor
" Set mapping and key timeouts
set timeout
set timeoutlen=1000 " timeout for leader key
set ttimeoutlen=10 " timeout for esc key
set updatetime=300 " 300ms of no cursor movement to trigger CursorHold
" Show if leader key is pressed
set showcmd
set cmdheight=2 " Give more space for displaying messages.
" Correct backspace
set backspace=indent,eol,start
" Improve breaks
set showbreak=>>>
set breakindent
" Disable mouse
set mouse=c
set guioptions+=lrbmTLce
set guioptions-=lrbmTLce
set guioptions+=c
" Disable ZZ to close vim
nnoremap Z <Nop>
nnoremap ZZ <Nop>
" =============================================================================
" Performance
" =============================================================================
" Improve performance of matchparen plugin
" This is DISABLING it!
let g:loaded_matchparen = 1 " Don't show matching parens.
set noshowmatch " Don't show matching braces.
let g:matchparen_timeout = 2
let g:matchparen_insert_timeout = 2
" Syntax highlighting for lua in .vimrc
let g:vimsyn_embed = 'l'
" Improve performance (not necessary on iTerm2 Beta)
" set lazyredraw
" Disable syntax highlighting long lines
set synmaxcol=300
" Disable syntax highlighting in large files
autocmd BufReadPre * if getfsize(expand("%")) > 10000000 | set syntax=OFF | endif
" =============================================================================
" Buffer Switching
" =============================================================================
" Improve :b switch menu
set wildchar=<Tab> wildmenu wildmode=full
" Buffer switching
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
" Jump to buffers with Ngb
let c = 1
while c <= 99
execute "nnoremap " . c . "gb :" . c . "b\<CR>"
let c += 1
endwhile
" Cygwin cursor fix.
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
" Write undo tree to a file to resume from next time the file is opened.
if has("persistent_undo")
set undolevels=2000 " The number of undo items to remember
set undofile " Save undo history to files locally
set undodir=$HOME/.vimundo " Set the directory of the undofile
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
endif
" When running as diff.
if &diff
set modifiable
set noreadonly
if tabpagenr('$') == 1
nnoremap ZZ :wqall<cr>
endif
endif
" Theme
if has('nvim')
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
set background=dark
colorscheme solarized
" colorscheme solarized8
" =============================================================================
" Custom Filetypes
" =============================================================================
au BufRead,BufNewFile *.ds set filetype=rgbds " GameBoy Assembly
au BufRead,BufNewFile *.fl,*.flex,*.l,*.lm setlocal ft=lex " Flex
au BufRead,BufNewFile *.y,*.ypp,*.ym setlocal ft=yacc " Bison
au BufRead,BufNewFile *.man setlocal ft=groff " Groff/Troff
au BufRead,BufNewFile *.mm setlocal ft=objcpp " Objective-C++
au BufRead,BufNewFile *.m setlocal ft=objc " Objective-C
au BufRead,BufNewFile *.jsx set ft=javascript.jsx " Javascript
au BufRead,BufNewFile *.tsx set ft=typescript.tsx " TypescriptX
au BufRead,BufNewFile *.ts set ft=typescript " Typescript
" =============================================================================
" Set syntax options
" =============================================================================
" Highlight trailing whitespace in c files
let c_space_errors = 1
" Custom no-fold in my c.vim
let c_no_block_fold = 1
" Don't fold comments
let c_no_comment_fold = 1
" Don't fold #if 0 blocks
let c_no_if0_fold = 1
" =============================================================================
" Bindings
" =============================================================================
" Warn about doing the wrong undo (U instead of u).
nnoremap U :echo " < < ===== C H E C K C A P S L O C K ===== > > "<CR>
" Map redo to r instead of C-r
nnoremap j <C-r>
" Map Vim Expression valuation
inoremap <c-a> <c-r>
" Convenient pasting.
set pastetoggle=<F2>
" Removed due to blocking super awesome multiline edit mode.
" Convenient copy to clipboard.
" vnoremap <C-c> :w !pbcopy<CR><CR>
" noremap <C-v> :r !pbpaste<CR><CR>
" Unhighlight searches
" using <esc> for this, behaves weird
nnoremap <C-d> :noh<return>
" Reselect visual blocks after movement
vnoremap < <gv
vnoremap > >gv
" Keep search matches in the middle of the window.
nnoremap ? nzzzv
nnoremap - Nzzzv
" Move by words
" nnoremap B B
" nnoremap S W
nnoremap <S-b> b
nnoremap <S-s> w
vnoremap <S-b> b
vnoremap <S-s> w
" Go to end of word
nnoremap w e
vnoremap w e
" Key map optimizations for Bone 2 Layout
" Normal Mode remaps.
nnoremap b <Left>
nnoremap r <Up>
nnoremap n <Down>
nnoremap s <Right>
nnoremap gn gj
nnoremap gr gk
" Visual and Select Mode remaps.
vnoremap b <Left>
vnoremap r <Up>
vnoremap n <Down>
vnoremap s <Right>
vnoremap gn gj
vnoremap gr gk
" Move half page up / down
nnoremap ( <C-D>
nnoremap ) <C-U>
vnoremap ( <C-D>
vnoremap ) <C-U>
" Move line up down
nnoremap <S-n> <C-e>
nnoremap <S-r> <C-y>
vnoremap <S-n> <C-e>
vnoremap <S-r> <C-y>
" Insert newline
" nnoremap <CR> o<Esc>
" inoremap <C-O> <Esc>o
" Split switching
nnoremap <C-p> <C-W>w
nnoremap <C-n> <C-W>j
nnoremap <C-r> <C-W>k
nnoremap <C-b> <C-W>h
nnoremap <C-s> <C-W>l
" Split resizing
nnoremap ! :vertical resize -5<CR>
nnoremap = :vertical resize +5<CR>
nnoremap < :resize +5<CR>
nnoremap > :resize -5<CR>
" Even out splits
nnoremap <C-y>w <C-W>=
nnoremap <C-y>m <C-W>_
nnoremap <C-y>t <C-W>T
nnoremap <C-y>l :ZoomWin<CR>
" Split Creating
nnoremap <C-i> :vsplit<CR>
nnoremap <C-t> :split<CR>
" Split killing
command! Bd bp\|bd \#
nnoremap <C-q> :BD<CR>
nnoremap <C-w> :bd<CR>
" Close / Open quickfix
nnoremap <Leader>qq :cclose<CR>
nnoremap <Leader>qc :cclose<CR>
nnoremap <Leader>qo :copen<CR>
" Map Y to y$, to behave like D and C
nnoremap Y y$
" Jump back in time
nnoremap <Leader>. <C-t>
" =============================================================================
" Tab navigation
" =============================================================================
nnoremap <C-u>b :tabprevious<CR>
nnoremap <C-u>s :tabnext<CR>
nnoremap <C-u>n :tabedit<CR>
nnoremap <C-u>c :tabclose<CR>
nnoremap <C-u>1 1gt
nnoremap <C-u>2 2gt
nnoremap <C-u>3 3gt
nnoremap <C-u>4 4gt
nnoremap <C-u>5 5gt
nnoremap <C-u>6 6gt
cabbrev tabv tab sview +setlocal\ nomodifiable
" =============================================================================
" Indent
" =============================================================================
" Use two spaces to indent js/ts files
autocmd FileType javascript setlocal tabstop=2
autocmd FileType javascript setlocal shiftwidth=2
autocmd FileType javascript.jsx setlocal tabstop=2
autocmd FileType javascript.jsx setlocal shiftwidth=2
autocmd FileType typescript setlocal tabstop=2
autocmd FileType typescript setlocal shiftwidth=2
autocmd FileType typescript set makeprg=tsc\ $*
autocmd FileType typescript.tsx setlocal tabstop=2
autocmd FileType typescript.tsx setlocal shiftwidth=2
autocmd FileType typescript.tsx set makeprg=tsc\ $*
" Setup comment string
autocmd FileType javascript setlocal commentstring=/*\ %s\ */
autocmd FileType javascript.jsx setlocal commentstring=/*\ %s\ */
autocmd FileType typescript setlocal commentstring=/*\ %s\ */
autocmd FileType typescript.tsx setlocal commentstring=/*\ %s\ */
autocmd FileType lalrpop setlocal commentstring=//\ %s
" Use two spaces to indent json files
autocmd FileType json setlocal tabstop=2
autocmd FileType json setlocal shiftwidth=2
" Use Tabs in Makefiles
autocmd FileType make setlocal noexpandtab
" Use two spaces in gn files
autocmd FileType gn setlocal tabstop=2
autocmd FileType gn setlocal shiftwidth=2
" Use two spaces in yaml files
autocmd FileType yaml setlocal tabstop=2
autocmd FileType yaml setlocal shiftwidth=2
" =============================================================================
" Folding Config
" =============================================================================
nnoremap z( zj
nnoremap z) zk
augroup vimrc
autocmd!
" Set foldmethod indent AND manual
autocmd BufReadPre * setlocal foldmethod=indent
autocmd BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
" Open all folds at startup
autocmd BufRead * normal zR
augroup END
augroup filetype_cs
autocmd!
" Set folding by syntax for C# (Unity) files
autocmd FileType cs setlocal foldmethod=syntax
autocmd FileType cs let b:match_words = '\s*#\s*region.*$:\s*#\s*endregion'
" Close all folds
autocmd BufRead *.cs normal zM
augroup END
augroup filetype_cpp
autocmd!
" Create custom doxygen comment style
autocmd FileType cpp syn region doxygenComment start="/\*\!" end="\*/" fold
autocmd FileType cpp hi link doxygenComment cError
" Fold based on our custom syntax.
autocmd FileType cpp setlocal foldmethod=syntax
" Close all folds.
autocmd BufRead *.cxx,*.hxx,*.cpp,*.hpp normal zM
augroup END
" =============================================================================
" Set 80 column limit.
" =============================================================================
if exists('+colorcolumn')
set colorcolumn=80
highlight ColorColumn guibg=#004653
" except for mail
autocmd FileType mail set colorcolumn=72
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
" =============================================================================
" Setup GUI font
" =============================================================================
if has('gui_running')
if has('nvim')
" Done in ginit.vim
" has('gui_running') is always false.
else
set t_Co=256
set guifont=PragmataPro\ Mono:h9
set lsp=0
" HighDPI
" set guifont=Input:h9:w4.5
" set lsp=-2
endif
endif