-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
1143 lines (968 loc) · 32.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
" Current config assumes nvim and vim-plug
" Disable this to disable heavier config options for lightweight environments
let g:full_config = 1
" vim mode preferred!
set nocompatible
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
if (has("termguicolors"))
set termguicolors
endif
" set xterm title, and inform vim of screen/tmux's syntax for doing the same
set titlestring=nvim\ %{expand(\"%t\")}
if &term =~ "^screen"
" pretend this is xterm. it probably is anyway, but if term is left as
" `screen`, vim doesn't understand ctrl-arrow.
if &term == "screen-256color"
set term=xterm-256color
else
set term=xterm
endif
" gotta set these *last*, since `set term` resets everything
set t_ts=k
set t_fs=\
endif
set title
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" backups and other junky files
set backupdir=~/.vim/backup " get backups outta here
set directory=~/.vim/swap " get swapfiles outta here
set writebackup " temp backup during write
set undodir=~/.vim/undo " persistent undo storage
set undofile " persistent undo on
" user interface
set history=1000 " remember command mode history
set laststatus=2 " always show status line
set lazyredraw " don't update screen inside macros, etc
set number " line numbers
set matchtime=2 " ms to show the matching paren for showmatch
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set showmatch " show matching brackets while typing
"set relativenumber " line numbers spread out from 0
set cursorline " highlight current line
set display=lastline,uhex " show last line even if too long; use <xx>
" Naive native indent guides
" set list lcs=tab:\|\
" regexes
set incsearch " do incremental searching
set ignorecase " useful more often than not
set smartcase " case-sens when capital letters
set gdefault " s///g by default
" whitespace
set autoindent " keep indenting on <CR>
set shiftwidth=4 " one tab = four spaces (autoindent)
set softtabstop=-1 " Disable sts
set tabstop=4 " Tabs are 4 characters
set shiftround " only indent to multiples of shiftwidth
set fileformats=unix,dos " unix linebreaks in new files please
set listchars=tab:↹·,extends:⇉,precedes:⇇,trail:␠,nbsp:␣,space:⋅,eol:↴
" appearance of invisible characters
set formatoptions=crqlj " wrap comments, never autowrap long lines
" wrapping
"set colorcolumn=+1 " highlight 81st column
set linebreak " break on what looks like boundaries
set showbreak=↳\ " shown at the start of a wrapped line
set virtualedit=block " allow moving visual block into the void
" gui stuff
set mouse=a " terminal mouse when possible
set guifont=Fira\ Code\ Retina:h9
set guicursor+=a:blinkon1000
" unicode
set encoding=utf-8 " best default encoding
setglobal fileencoding=utf-8 " ...
set nobomb " do not write utf-8 BOM!
set fileencodings=ucs-bom,utf-8,iso-8859-1
" order to detect Unicodeyness
set updatetime=250
" miscellany
set autoread " reload changed files
set scrolloff=2 " always have 2 lines of context on the screen
set foldmethod=syntax
set foldlevel=99
set timeoutlen=1000 " wait 1s for mappings to finish
set ttimeoutlen=0 " wait 0s for xterm keycodes to finish
set nrformats-=octal " don't try to auto-increment 'octal'
set grepprg=rg\ --vimgrep
set splitright
set splitbelow
set diffopt+=vertical
set hidden
set wildmode=longest,list,full
set wildmenu
set completeopt=menuone,noselect
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Bindings
" Stuff that clobbers default bindings
" Force ^U and ^W in insert mode to start a new undo group
inoremap <c-u> <c-g>u<c-u>
inoremap <c-w> <c-g>u<c-w>
" Leader
let mapleader = ' '
let g:mapleader = ' '
let maplocalleader = ','
let g:maplocalleader = ','
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python'
" For vim-table-mode to not clobber with Align
let g:table_mode_tableize_map = '<Leader>tct'
" Disable F1 Help
map <F1> <Esc>
imap <F1> <Esc>
" Ctrl+backspace delete word
" Doesn't work in gnome-terminal, works in neovim-qt
imap <C-BS> <C-W>
" System clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
vnoremap <leader>d "+d
nnoremap <leader>D "+dg_
nnoremap <leader>d "+d
vnoremap <leader>x "+x
nnoremap <leader>X "+xg_
nnoremap <leader>x "+x
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P
" Copy current paths to system clipboard
" Relative path
nnoremap <leader>cf :let @+=expand("%")<CR>
" Absolute path
nnoremap <leader>cF :let @+=expand("%:p")<CR>
" Basename
nnoremap <leader>ct :let @+=expand("%:t)<CR>
" Parent directory
nnoremap <leader>ch :let @+=expand("%:p:h")<CR>
imap <C-C> "+y
imap <C-X> "+x
inoremap <C-Q> <C-V>
cnoremap <C-Q> <C-V>
imap <C-V> <C-R>+
cmap <C-V> <C-R>+
" Saving
nmap <C-S> :w<CR>
imap <C-S> <Esc>:w<CR>a
" Reload all open buffers
nmap <A-y> :bufdo e<CR>
" Text objects
" ib = inner buffer
onoremap ib :exec "normal! ggVG"<CR>
" iv = current viewable text in the buffer
onoremap iv :exec "normal! HVL"<CR>
" Insert date
nnoremap <F5> "=strftime("%Y-%m-%d")<CR>p
nnoremap <leader><F5> "=strftime("%Y-%m-%d")<CR>P
inoremap <F5> <C-R>=strftime("%Y-%m-%d")<CR>
" From http://vim.wikia.com/wiki/Quickly_adding_and_deleting_empty_lines
" Shift-Alt-j/k deletes blank line below/above, and Alt-j/k inserts.
nnoremap <silent><S-A-j> m`:silent +g/\m^\s*$/d<CR>``:noh<CR>
nnoremap <silent><S-A-k> m`:silent -g/\m^\s*$/d<CR>``:noh<CR>
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>
" Move lines
" From http://vim.wikia.com/wiki/Moving_lines_up_or_down
nnoremap <C-j> :m .+1<CR>==
nnoremap <C-k> :m .-2<CR>==
inoremap <C-j> <Esc>:m .+1<CR>==gi
inoremap <C-k> <Esc>:m .-2<CR>==gi
vnoremap <C-j> :m '>+1<CR>gv=gv
vnoremap <C-k> :m '<-2<CR>gv=gv
" Scroll faster
nnoremap <C-e> 10<C-e>
nnoremap <C-y> 10<C-y>
nnoremap <C-CR> i<CR><Esc>
nmap <silent> ]h :cn<CR>
nmap <silent> [h :cp<CR>
" Select previous paste
nnoremap gp `[v`]
" Search for current word
" http://vim.wikia.com/wiki/Search_for_current_word_in_multiple_files
nnoremap gr :grep <cword><CR>
inoremap <silent><F2> <Esc>v`^me<Esc>gi<C-o>:call Ender()<CR>
function! Ender()
let endchar = nr2char(getchar())
execute "normal \<End>a".endchar
normal `e
normal me
endfunction
" Disable arrow movement in normal mode, resize splits instead.
nnoremap <C-Up> :resize +1<CR>
nnoremap <C-Down> :resize -1<CR>
nnoremap <C-Left> :vertical resize -1<CR>
nnoremap <C-Right> :vertical resize +1<CR>
nnoremap <Up> :resize +10<CR>
nnoremap <Down> :resize -10<CR>
nnoremap <Left> :vertical resize -10<CR>
nnoremap <Right> :vertical resize +10<CR>
" Highlight current line (requires LineHighlight highlight definition)
nnoremap <leader>l :call matchadd('LineHighlight', '\%'.line('.').'l')<CR>
" Clear all highlights
nnoremap <leader>cl :call clearmatches()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Miscellaneous autocmds
" Automatically delete swapfiles older than the actual file.
" Look at this travesty. vim already has this information but doesn't expose
" it, so I have to reparse the swap file. Ugh.
function! s:SwapDecide()
python << endpython
import os
import struct
import vim
# Format borrowed from:
# https://github.com/nyarly/Vimrc/blob/master/swapfile_parse.rb
SWAPFILE_HEADER = "=BB10sLLLL40s40s898scc"
size = struct.calcsize(SWAPFILE_HEADER)
with open(vim.eval('v:swapname'), 'rb') as f:
buf = f.read(size)
(
id0, id1, vim_version, pagesize, writetime,
inode, pid, uid, host, filename, flags, dirty
) = struct.unpack(SWAPFILE_HEADER, buf)
try:
# Test whether the pid still exists. Could get fancy and check its name
# or owning uid but :effort:
os.kill(pid, 0)
except OSError:
# NUL means clean, \x55 (U) means dirty. Yeah I don't know either.
if dirty == b'\x00':
# Appears to be from a crash, so just nuke it
vim.command('let v:swapchoice = "d"')
endpython
endfunction
if has("python")
augroup eevee_swapfile
autocmd!
autocmd SwapExists * call s:SwapDecide()
augroup END
endif
let g:markdown_fenced_languages = ['html', 'javascript', 'python', 'rust', 'svelte', 'c', 'bash']
let g:polyglot_disabled = ['autoindent', 'svelte']
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
call plug#begin('~/.vim/plugged')
" Essentials
" Plug 'zefei/vim-wintabs'
Plug 'tiagovla/scope.nvim'
Plug 'akinsho/bufferline.nvim'
Plug 'ojroques/nvim-bufdel'
Plug 'sheerun/vim-polyglot'
Plug 'evanleck/vim-svelte', {'branch': 'main'}
Plug 'windwp/nvim-autopairs'
Plug 'wakatime/vim-wakatime'
Plug 'kylechui/nvim-surround'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-sleuth'
Plug 'chaoren/vim-wordmotion'
Plug 'gbprod/yanky.nvim'
Plug 'mhinz/vim-sayonara'
" File types and syntaxes
Plug 'plasticboy/vim-markdown'
Plug 'dhruvasagar/vim-table-mode'
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'rust-lang/rust.vim'
Plug 'hail2u/vim-css3-syntax'
Plug 'lervag/vimtex'
" Colorschemes
Plug 'sainnhe/gruvbox-material'
Plug 'folke/tokyonight.nvim'
Plug 'sainnhe/edge'
Plug 'RRethy/nvim-base16'
Plug 'lourenci/github-colors'
Plug 'sainnhe/sonokai'
Plug 'dracula/vim'
Plug 'Mofiqul/adwaita.nvim'
Plug 'glepnir/zephyr-nvim'
Plug 'savq/melange'
Plug 'tjdevries/colorbuddy.vim'
Plug 'bkegley/gloombuddy'
" Heavier
if get(g:, 'full_config')
Plug 'folke/snacks.nvim'
Plug 'stevearc/dressing.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'simrat39/rust-tools.nvim'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'nvim-tree/nvim-tree.lua'
Plug 'ray-x/lsp_signature.nvim'
Plug 'lewis6991/gitsigns.nvim'
Plug 'saadparwaiz1/cmp_luasnip'
Plug 'L3MON4D3/LuaSnip'
Plug 'folke/lsp-colors.nvim'
Plug 'windwp/nvim-ts-autotag'
Plug 'nvim-treesitter/nvim-treesitter', { 'do': ':TSUpdate' }
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
" Plug 'zbirenbaum/neodim'
Plug 'p00f/nvim-ts-rainbow'
Plug 'JoosepAlviste/nvim-ts-context-commentstring'
Plug 'cshuaimin/ssr.nvim'
Plug 'sindrets/diffview.nvim'
Plug 'numToStr/Comment.nvim'
Plug 'kazhala/close-buffers.nvim'
Plug 'kana/vim-repeat'
Plug 'kshenoy/vim-signature'
Plug 'Valloric/MatchTagAlways'
Plug 'justinmk/vim-gtfo'
Plug 'arthurxavierx/vim-caser'
Plug 'DougBeney/pickachu'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
Plug 'luochen1990/rainbow'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'junegunn/fzf'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'branch': 'main', 'do': 'make' }
Plug 'mcchrish/nnn.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'nvim-lualine/lualine.nvim'
Plug 'severin-lemaignan/vim-minimap', {'do': ':!cargo install --locked code-minimap'}
Plug 'kevinhwang91/nvim-bqf'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-abolish'
Plug 'ap/vim-css-color'
Plug 'NvChad/nvim-colorizer.lua'
Plug 'amadeus/vim-convert-color-to'
Plug 'Quramy/vim-js-pretty-template'
Plug 'godlygeek/tabular'
Plug 'wesQ3/vim-windowswap'
Plug 'moll/vim-node'
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
Plug 'majutsushi/tagbar'
Plug 'vim-php/tagbar-phpctags.vim', {'do': 'make'}
Plug 'ryanoasis/vim-devicons'
Plug 'mbbill/undotree'
Plug 'cplaursen/vim-isabelle'
Plug 'whonore/Coqtail'
" Formatters
Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
" After upgrading python, nvim will usually launch with an error
" saying that the black module can't be found.
" To fix this, `rm -r ~/.local/share/nvim/black` and relaunch.
Plug 'psf/black', { 'branch': 'stable' }
Plug 'vim-scripts/Align'
Plug 'vim-scripts/SQLUtilities'
" Git
Plug 'gregsexton/gitv'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tommcdo/vim-fubitive'
Plug 'shumphrey/fugitive-gitlab.vim'
Plug 'christoomey/vim-conflicted'
Plug 'rhysd/conflict-marker.vim'
endif
call plug#end()
let g:html_indent_style1 = 'inc'
let g:html_indent_script1 = 'inc'
let g:html_indent_inctags = 'html,body,head,tbody,p'
let g:wordmotion_mappings = {
\ 'w': '<A-w>',
\ 'b': '<A-b>',
\ 'e': '<A-e>',
\ 'ge': 'g<A-e>',
\ 'aw': 'a<A-w>',
\ 'iw': 'i<A-w>',
\ '<C-R><C-W>': '<C-R><A-w>'
\}
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
let g:jsx_ext_required = 0
let g:rustfmt_autosave = 1
let g:AutoPairsCenterLine = 0
let g:pandoc#formatting#mode = 'h'
let g:pandoc#modules#disabled = ['completion']
let g:pandoc#filetypes#pandoc_markdown = 0
let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 0
let g:vimtex_compiler_progname = 'nvr'
set conceallevel=1
let g:tex_conceal='abdmg'
" Settings
if get(g:, 'full_config')
let g:session_autoload = 'no'
let g:session_autosave = 'no'
let g:session_menu = 0
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
let g:mta_filetypes = {
\ 'html': 1,
\ 'htmldjango': 1,
\ 'javascript.jsx': 1,
\ 'jsx': 1,
\ 'njk': 1,
\ 'svelte': 1,
\ 'vue': 1,
\ 'xhtml': 1,
\ 'xml': 1
\}
let g:closetag_filenames = '*.xml,*.html,*.xhtml,*.njk,*.svelte,*.js,*.jsx,*.tsx,*.vue,*.blade.php'
let g:closetag_filetypes = 'xml,html,xhtml,htmldjango,svelte,jsx,javascript.jsx,typescriptreact,vue,blade'
let g:pickachu_default_date_format = "%Y-%m-%d"
let g:yoinkIncludeDeleteOperations = 1
let g:nremap = {'[e': '', ']e': ''}
call jspretmpl#register_tag('css', 'css')
" call jspretmpl#register_tag('gql', 'graphql')
let g:rainbow_active = 1
let g:prettier#autoformat_config_present = 1
let g:prettier#autoformat_require_pragma = 0
let g:prettier#autoformat_config_files = [".prettierrc.json", ".prettierrc"]
let g:svelte_preprocessors = ['typescript']
endif
" Keymaps
map <C-P> :Telescope git_files<CR>
map <Leader><C-P> :Telescope find_files<CR>
map <C-;> :Telescope scope buffers<CR>
map <C-H> :BufferLineCyclePrev<CR>
map <C-L> :BufferLineCycleNext<CR>
" map <C-L> <Plug>(wintabs_next)
map <C-T>h :BufferLineMovePrev<CR>
map <C-T>l :BufferLineMoveNext<CR>
map <C-T>c :BufDel<CR>
map <C-T>o :BufferLineCloseOthers<CR>
" map <C-T>l <Plug>(wintabs_move_right)
" map <C-T>w <Plug>(wintabs_close)
" map <C-T>c <Plug>(wintabs_close)
" map <C-T>o <Plug>(wintabs_only)
" map <C-W>c <Plug>(wintabs_close_window)
" map <C-W>o <Plug>(wintabs_only_window)
map <C-_> gcc
nmap - <Plug>(YankyPreviousEntry)
nmap + <Plug>(YankyNextEntry)
nmap y <Plug>(YankyYank)
xmap y <Plug>(YankyYank)
nmap p <Plug>(YankyPutAfter)
xmap p <Plug>(YankyPutAfter)
nmap P <Plug>(YankyPutBefore)
xmap P <Plug>(YankyPutBefore)
if get(g:, 'full_config')
nmap <F8> :TagbarToggle<CR>
command! Tabc WintabsCloseVimtab
command! Tabo WintabsOnlyVimtab
command! Tags TagbarToggle
map <A-c> :Pickachu<CR>
map <A-o> :Pickachu file<CR>
map <A-d> :Pickachu date<CR>
nmap <Leader>= <Plug>(PrettierAsync)
nmap <silent> <A-m> :MinimapToggle<CR>
nmap <F4> :UndotreeToggle<CR>
lua << EOF
require('snacks').setup({
bigfile = { enabled = true },
bufdelete = { enabled = true },
quickfile = { enabled = true },
rename = { enabled = true },
-- notifier = { enabled = true },
-- words = { enabled = true },
})
require('lualine').setup({
sections = {
lualine_a = {'mode'},
lualine_b = {'diff', 'diagnostics'},
lualine_c = {{'filename', path=1}},
lualine_x = {'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
})
require('scope').setup()
require('bufdel').setup {
quit = false,
}
require('bufferline').setup({
options = {
close_command = "BufDel %d",
right_mouse_command = "BufDel %d",
separator_style = 'thin',
diagnostics = 'nvim_lsp',
hover = {
enabled = true,
delay = 200,
reveal = {'close'}
},
offsets = {
{
filetype = 'NvimTree',
text = '',
text_align = 'left',
separator = true,
}
}
}
})
require('Comment').setup()
require('nvim-surround').setup()
require('nvim-autopairs').setup({
check_ts = true,
})
require('yanky').setup({
preserve_cursor_position = {
enabled = true,
},
system_clipboard = {
sync_with_ring = false,
},
highlight = {
on_put = false,
on_yank = false,
timer = 200,
},
})
require('ibl').setup {
enabled = false,
exclude = { filetypes = { "help" } },
}
local action_layout = require('telescope.actions.layout')
telescope = require('telescope')
telescope.setup {
defaults = {
preview = {
hide_on_startup = true
},
mappings = {
n = {
['<A-p>'] = action_layout.toggle_preview
},
i = {
-- Close pane with Esc directly from insert mode
-- ["<Esc>"] = actions.close,
['<A-p>'] = action_layout.toggle_preview
}
}
}
}
telescope.load_extension('fzf')
telescope.load_extension('scope')
require('gitsigns').setup {
on_attach = function (bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
end
local opts = { noremap=true, silent=true }
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']c', '<cmd>Gitsigns next_hunk<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[c', '<cmd>Gitsigns prev_hunk<CR>', opts)
vim.api.nvim_set_hl(0, 'GitSignsAdd', { link = 'GitGutterAdd' })
vim.api.nvim_set_hl(0, 'GitSignsChange', { link = 'GitGutterChange' })
vim.api.nvim_set_hl(0, 'GitSignsDelete', { link = 'GitGutterDelete' })
vim.api.nvim_set_hl(0, 'GitSignsTopdelete', { link = 'GitGutterDelete' })
vim.api.nvim_set_hl(0, 'GitSignsChangedelete', { link = 'GitGutterChange' })
end
}
require('nvim-tree').setup {
disable_netrw = false,
system_open = {
cmd = "xdg-open",
},
update_cwd = true,
diagnostics = {
enable = true,
},
modified = {
enable = true,
},
git = {
ignore = false
}
}
vim.g.skip_ts_context_commentstring = true
require('nvim-treesitter.configs').setup {
ensure_installed = "all",
ignore_install = { "phpdoc" },
highlight = {
enable = true, -- false will disable the whole extension
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = 'gnn',
node_incremental = 'grn',
scope_incremental = 'grc',
node_decremental = 'grm',
},
},
-- indent = {
-- enable = true,
-- },
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
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',
},
},
},
-- nvim-ts-rainbow
rainbow = {
enable = false,
extended_mode = true,
},
}
require('nvim-ts-autotag').setup()
require('ts_context_commentstring').setup()
vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
})
-- require('neodim').setup()
-- Matches default nvim-tree icons
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
local lspconfig = require('lspconfig')
lspconfig_on_attach = function(client, buffer)
local opts = { noremap=true, silent=true, buffer=buffer }
vim.keymap.set('n', ']e', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '[e', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<Leader>=', vim.lsp.buf.format, opts)
vim.keymap.set('n', '<A-h>', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<A-a>', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', '<A-f>', function() vim.lsp.buf.code_action({ context = { only = {"source.fixAll"} }, apply = true }) end, opts)
vim.keymap.set('n', '<A-r>', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<A-q>', function() vim.lsp.stop_client(vim.lsp.get_active_clients()) end, opts)
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.format()' ]]
vim.cmd [[ command! LSPInfo execute 'lua print(vim.inspect(vim.lsp.buf_get_clients()))' ]]
vim.cmd [[ autocmd CursorHold * lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"}) ]]
require'lsp_signature'.on_attach()
end
lspconfig_capabilities = require('cmp_nvim_lsp').default_capabilities()
-- npm i -g vscode-langservers-extracted svelte-language-server @tailwindcss/language-server intelephense
-- pacman -S rust-analyzer pyright typescript-language-server
local lsp_servers = {
'cssls', -- https://github.com/hrsh7th/vscode-langservers-extracted
'eslint', -- https://github.com/hrsh7th/vscode-langservers-extracted
'html', -- https://github.com/hrsh7th/vscode-langservers-extracted
'intelephense', -- https://intelephense.com/
'jsonls', -- https://github.com/hrsh7th/vscode-langservers-extracted
'svelte', -- https://github.com/sveltejs/language-tools/tree/master/packages/language-server
'tailwindcss', -- https://github.com/tailwindlabs/tailwindcss-intellisense
'jdtls', -- https://projects.eclipse.org/projects/eclipse.jdt.ls
'gopls', -- https://github.com/golang/tools/tree/master/gopls
-- configured automatically with rust-rools
-- 'rust_analyzer', -- https://github.com/rust-analyzer/rust-analyzer
-- more configured manually below
}
for _, lsp in ipairs(lsp_servers) do
lspconfig[lsp].setup {
on_attach = lspconfig_on_attach,
capabilities = lspconfig_capabilities,
}
end
-- https://github.com/denoland/deno
lspconfig.denols.setup {
on_attach = lspconfig_on_attach,
capabilities = lspconfig_capabilities,
root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
settings = {
deno = {
enable = true,
lint = true,
unstable = true,
}
}
}
-- https://github.com/typescript-language-server/typescript-language-server
lspconfig.ts_ls.setup {
on_attach = lspconfig_on_attach,
capabilities = lspconfig_capabilities,
root_dir = function (filename, bufnr)
local denoRootDir = lspconfig.util.root_pattern("deno.json", "deno.jsonc")(filename)
if denoRootDir then return nil end
return lspconfig.util.root_pattern("package.json")(filename)
end,
single_file_support = false,
}
-- https://github.com/microsoft/pyright
lspconfig.pyright.setup {
on_attach = function(client, buffer)
lspconfig_on_attach(client, buffer)
local opts = { noremap=true, silent=true, buffer=buffer }
-- disable rename in favor of pyright
vim.keymap.set(
'n',
'<A-r>',
function() vim.lsp.buf.rename(nil, { name = "pyright" }) end,
opts
)
end,
capabilities = lspconfig_capabilities
}
-- https://github.com/python-lsp/python-lsp-server
lspconfig.pylsp.setup {
on_attach = function(client, buffer)
lspconfig_on_attach(client, buffer)
local opts = { noremap=true, silent=true, buffer=buffer }
-- disable rename in favor of pyright
vim.keymap.set(
'n',
'<A-r>',
function() vim.lsp.buf.rename(nil, { name = "pyright" }) end,
opts
)
end,
capabilities = lspconfig_capabilities,
settings = {
pylsp = {
plugins = {
-- https://github.com/python-lsp/python-lsp-ruff
ruff = {
enabled = true,
},
jedi_completion = {
enabled = false
},
jedi_definition = {
enabled = false
},
jedi_hover = {
enabled = false
},
jedi_references = {
enabled = false
},
jedi_signature_help = {
enabled = false
},
jedi_symbols = {
enabled = false
},
mccabe = {
enabled = false
},
preload = {
enabled = false
},
yapf = {
enabled = false
},
pylint = {
-- disabled by default
enabled = false,
-- Use pylint binary, slower but basically required
executable = "pylint",
},
}
}
}
}
-- rust-tools
local rt = require 'rust-tools'
rt.setup {
server = {
on_attach = lspconfig_on_attach,
capabilities = lspconfig_capabilities,
standalone = true,
},
tools = {
inlay_hints = { auto = false }
}
}
local luasnip = require 'luasnip'
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
-- nvim-cmp
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
preselect = cmp.PreselectMode.None,
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}