-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.vim
More file actions
2244 lines (1985 loc) · 69.5 KB
/
init.vim
File metadata and controls
2244 lines (1985 loc) · 69.5 KB
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
" ==
"
" === Auto load for first time uses
" ===
"silent curl -sL install-node.vercel.app/lts | bash
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
autocmd!
autocmd CursorMoved * call ShowFugitiveFileName()
augroup END
augroup PreserveNoEOL
autocmd!
" Before write: if buffer is currently marked as no end-of-line, preserve it
autocmd BufWritePre * if !&l:endofline | let b:__save_bin=&l:binary | let b:__save_eol=&l:endofline | setlocal binary noeol | endif
" After write: restore options if we changed them
autocmd BufWritePost * if exists('b:__save_bin') | let &l:binary=b:__save_bin | let &l:endofline=b:__save_eol | unlet b:__save_bin b:__save_eol | endif
augroup END
let s:prevtabnum=tabpagenr('$')
augroup TabClosed
autocmd! TabEnter * :if tabpagenr('$')<s:prevtabnum && tabpagenr()>1
\ | tabprevious
\ |endif
\ |let s:prevtabnum=tabpagenr('$')
augroup END
" let g:syntax_maxlines=999999
" syntax sync minlines=999999
" autocmd BufEnter * :syntax sync fromstart
:lua vim.lsp.inlay_hint.enable(false)
set laststatus=3
set scrolloff=10
set synmaxcol=0
set iskeyword+=-
set termguicolors
set noswapfile
set hidden
set ts=2
set encoding=utf-8
set autoindent
set noautochdir
set expandtab
set shiftwidth=4
set cursorline
set showmatch
set nobackup
set nowritebackup
set smartcase
set cmdheight=2
set timeoutlen=800
set updatetime=300
set shortmess+=c
set signcolumn=yes
set nocompatible
filetype plugin on
syntax on
set number
set relativenumber
set cursorline
set wrap
set showcmd
set wildmenu
set clipboard+=unnamedplus
set hlsearch
exec "nohlsearch"
set incsearch
set ignorecase
set ww+=h,l
set list
set listchars=eol:↓,tab:\ \ ┊,trail:●,extends:…,precedes:…,space:·
let mapleader=" "
let maplocalleader=" "
" calculate selected
vnoremap <LEADER>c yo<c-r>=<c-r>"<CR>
" copy current file path
nnoremap <space>cp :let @*=expand('%:t')<CR>:echo "path copied"<CR>
nnoremap <space>cfp :let @*=expand('%')<CR>:echo "full path copied"<CR>
" set number in each V selected lines from 0, 1, 2...
xnoremap <silent> <leader>in0 :<C-u>'<,'>s/\d\+\ze\D*$/\=line('.')-line("'<")/<CR>:noh<CR>
" start from 1
xnoremap <silent> <leader>in1 :<C-u>'<,'>s/\d\+\ze\D*$/\=line('.')-line("'<")+1/<CR>:noh<CR>
" paste to new line
function! Pcol(...) abort
let above = get(a:, 1, 0)
let col = virtcol('.')
execute 'normal!' above ? 'P' : 'p'
call cursor('.', col)
endfunction
" jump to head and tail
nnoremap H 0
vnoremap H 0
nnoremap L $
vnoremap L $
nnoremap j gj
nnoremap k gk
inoremap jk <ESC>
inoremap jh <ESC>^i
inoremap jl <ESC>A
inoremap jj <ESC>o
" copy to end
nnoremap Y y$
" b include current char
nnoremap db dvb
nnoremap cb cvb
nnoremap yb yvb
nnoremap <leader><down> 0i<cr><ESC>
nnoremap <leader><up> kdd
nnoremap = :noh<CR>
" scroll up and down
" nnoremap <c-d> 4j
" nnoremap <c-u> 4k
" vnoremap <c-d> 4j
" vnoremap <c-u> 4k
" search selected
nnoremap <silent> n <Cmd>execute('keepjumps normal! ' . v:count1 . 'n')<CR>
nnoremap <silent> N <Cmd>execute('keepjumps normal! ' . v:count1 . 'N')<CR>
nnoremap S :w<CR>
" nmap Q :call QuitWithQuickfixCheck()<CR>
nnoremap Q :Sayonara<CR>
function! QuitWithQuickfixCheck()
if get(getqflist({'winid':0}), 'winid', 0)
:cclose
:Sayonara<CR>
else
:Sayonara<CR>
endif
endfunction
nnoremap <LEADER>Q :qa!<CR>
" jump split window
" auto reload vimrc
augroup NVIMRC
autocmd!
autocmd BufWritePost init.vim exec ":so %"
augroup END
" split window
map <leader>sl :set nosplitright<CR>:set splitright<CR>:vnew<CR><c-w>l
map <leader>sv :set nosplitright<CR>:set splitright<CR>:vsplit $MYVIMRC<CR>
map <leader>sj :set nosplitbelow<CR>:set splitbelow<CR>:new<CR><c-w>j
" jump down/up/left/right split window
" quit vim
" resize window
" move pasted content indent to left/right
nnoremap <leader>, `[V`]<
nnoremap <leader>. `[V`]>
" new tab before current
nnoremap ti :-tabnew<CR>
" new tab after current
nnoremap ta :tabnew<CR>
" new tab after first tab
nnoremap tI :0tabnew<CR>
" new tab after last tab
nnoremap tA :$tabnew<CR>
"jump to left side tab
nnoremap <leader><left> :tabp<CR>
nnoremap th :tabp<CR>
nnoremap tH :tabfirst<CR>
"jump to right side tab
nnoremap <leader><right> :tabn<CR>
nnoremap tl :tabn<CR>
nnoremap tL :tablast<CR>
" duplicate current tab
nnoremap ts :tab split<CR>
" move current win to new tab
nnoremap tfs <C-W>T
"jump to N tab
nnoremap t1 :tabn1<CR>
nnoremap t2 :tabn2<CR>
nnoremap t3 :tabn3<CR>
nnoremap t4 :tabn4<CR>
nnoremap t5 :tabn5<CR>
nnoremap t6 :tabn6<CR>
nnoremap t7 :tabn7<CR>
nnoremap t8 :tabn8<CR>
nnoremap t9 :tabn9<CR>
function! EnsureTabExists(num)
let l:current_tab = tabpagenr()
if tabpagenr('$') < a:num
tabnew
execute 'tabnext ' . l:current_tab
endif
endfunction
function! s:printGitFileName()
" Get the current line
let l:p = searchpos('^[A-Z?] .\|^diff --', 'bnW')
let l:gitkeyline = getline(l:p[0])
" Extract the filename using a regular expression
" This assumes the format: diff --git a/.../filename b/.../filename
let l:match = matchlist(l:gitkeyline, 'diff --git a/.*\/\([^\/]*\) b/')
" Print the filename if matched
if len(l:match) > 1
echo "viewing file:" . l:match[1]
else
echo ""
endif
endfunction
function! ShowFugitiveFileName()
" Get the current buffer name
let l:bufname = expand('%')
" Check if it's a Fugitive buffer
if l:bufname =~# '^fugitive://'
" Extract the filename from the path
call s:printGitFileName()
else
" :echo expand('%') | redraw
endif
endfunction
" Optional: bind to a key
nnoremap <leader>t2 :call EnsureTabExists(2)<CR>
nnoremap <leader>t3 :call EnsureTabExists(3)<CR>
nnoremap <leader>t4 :call EnsureTabExists(4)<CR>
nnoremap <leader>t5 :call EnsureTabExists(5)<CR>
let s:last_list_win_type = 0
function! s:toggle_list()
if get(getloclist(0, {'winid':0}), 'winid', 0)
exec "lcl"
let s:last_list_win_type = 1
return
endif
if get(getqflist({'winid':0}), 'winid', 0)
exec "ccl"
let s:last_list_win_type = 2
return
endif
if s:last_list_win_type == 1
exec "lopen"
return
endif
if s:last_list_win_type == 2
exec "copen"
return
endif
endfunction
function! s:next_list()
if get(getloclist(0, {'winid':0}), 'winid', 0)
exec "lnext"
return
endif
if get(getqflist({'winid':0}), 'winid', 0)
exec "cnext"
return
endif
endfunction
function! s:prev_list()
if get(getloclist(0, {'winid':0}), 'winid', 0)
exec "lprev"
return
endif
if get(getqflist({'winid':0}), 'winid', 0)
exec "cprev"
return
endif
endfunction
" keymap for quick list/location list
nnoremap <leader>qq :call <SID>toggle_list()<CR>
nnoremap <leader>nn :call <SID>next_list()<CR>
nnoremap <leader>pp :call <SID>prev_list()<CR>
" delete all background buffers
nnoremap <leader>db :DeleteHiddenBuffers<CR>
" === vim-translator ===
" translation current word
nmap <silent> ty :Translate<CR>
" translation selected word
vmap <silent> ty :Translate<CR>
" Replace the text with translation
nmap <silent> tr <Plug>TranslateR
vmap <silent> tr <Plug>TranslateRV
" switch language
map tw :call <SID>toggle_lang()<CR>
function! s:toggle_lang()
if !exists("g:translator_target_lang")
let g:translator_target_lang = "zh"
endif
if g:translator_target_lang == "zh"
echo "switch g:translator_target_lang to en"
let g:translator_target_lang = 'en'
else
echo "switch g:translator_target_lang to zh"
let g:translator_target_lang = 'zh'
endif
endfunction
let g:translator_window_type = 'preview'
let g:translator_default_engines = ['google', 'bing']
" toggle full screen for splited window
map <LEADER>fs :call ToggleFs()<CR>
let s:enabled = 0
function! ToggleFs()
if s:enabled
normal <c-w>=
:exe "norm \<c-w>="
let s:enabled = 0
else
:exe "norm \<c-w>|"
let s:enabled = 1
endif
endfunction
call plug#begin('~/.vim/plugged')
" let g:plug_url_format = 'git@github.com:%s.git'
let g:plug_url_format = 'https://git::@github.com/%s.git'
" copilot
" Plug 'github/copilot.vim'
Plug 'Exafunction/windsurf.vim'
" chatgpt chat
Plug 'MunifTanjim/nui.nvim'
Plug 'jackMort/ChatGPT.nvim'
"Plug 'olimorris/codecompanion.nvim'
" Pretty Dress
Plug 'NLKNguyen/papercolor-theme'
Plug 'morhetz/gruvbox'
Plug 'overcache/NeoSolarized'
Plug 'doums/darcula'
Plug 'rebelot/kanagawa.nvim'
Plug 'catppuccin/vim'
Plug 'folke/tokyonight.nvim'
" Status line
Plug 'nvim-lualine/lualine.nvim'
" If you want to have icons in your statusline choose one of these
Plug 'nvim-tree/nvim-web-devicons'
Plug 'yimingwangdell/nvim-gps'
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release' }
" General Highlighter
" File navigation
Plug 'nvim-telescope/telescope.nvim',
Plug 'LukasPietzschmann/telescope-tabs'
Plug 'StefanBartl/telescope-selected-index'
Plug 'nvim-lua/plenary.nvim' " don't forget to add this one if you don't have it yet!
Plug 'nvim-tree/nvim-tree.lua'
Plug 'ThePrimeagen/harpoon', {'branch': 'harpoon2'}
Plug 'pechorin/any-jump.vim'
Plug 'francoiscabrol/ranger.vim'
Plug 'rbgrouleff/bclose.vim'
" Outline
Plug 'stevearc/aerial.nvim', {'tag': 'nvim-0.9'}
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate', 'tag': 'v0.10.0'}
Plug 'nvim-treesitter/nvim-treesitter-context'
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
" LSP
Plug 'mfussenegger/nvim-jdtls'
Plug 'williamboman/mason.nvim'
Plug 'neovim/nvim-lspconfig', {'tag': 'v2.5.0'}
Plug 'Saghen/blink.cmp'
" Plug 'ray-x/lsp_signature.nvim', {'branch': 'nvim-0.9'}
Plug 'folke/trouble.nvim'
" Snippets
Plug 'rafamadriz/friendly-snippets'
" Undo Tree
Plug 'mbbill/undotree'
" Git
Plug 'tpope/vim-fugitive'
Plug 'lewis6991/gitsigns.nvim'
Plug 'kdheepak/lazygit.nvim'
Plug 'sindrets/diffview.nvim'
" HTML, CSS, JavaScript, Typescript, PHP, JSON, etc.
" Go
Plug 'fatih/vim-go' , { 'for': ['go', 'vim-plug'], 'tag': '*' }
" Java
Plug 'uiiaoo/java-syntax.vim'
"string color
hi String guifg=#11111
" Markdown
Plug 'dkarter/bullets.vim'
Plug 'mzlogin/vim-markdown-toc'
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle', 'for': ['text', 'markdown', 'vim-plug'] }
Plug 'vimwiki/vimwiki' " best note taking tool
Plug 'nvim-orgmode/orgmode', {'tag': '0.6.0'}
"
" Editor Enhancement
Plug 'mhinz/vim-sayonara' " enhanced quit
Plug 'kevinhwang91/nvim-bqf' " quickfix zf search, zn new list <c-q> quit search
Plug 'romainl/vim-qf'
Plug 'junegunn/fzf'
Plug 'karunsiri/vim-delete-hidden-buffers'
Plug 'kwkarlwang/bufjump.nvim' "<M-o> jump back file
" Plug 'itchyny/vim-cursorword' " highlight current word
Plug 'RRethy/vim-illuminate'
Plug 'nvimtools/hydra.nvim'
Plug 'smoka7/multicursors.nvim'
Plug 'tomtom/tcomment_vim' " <space><space> to comment a line
Plug 'gbprod/substitute.nvim' " s to substitute
Plug 'machakann/vim-sandwich' " di" to delete inside of ""
Plug 'junegunn/vim-after-object' " da= to delete what's after =
Plug 'folke/flash.nvim' " best jump plugin
" Plug 'nvimdev/indentmini.nvim'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'matze/vim-move'
Plug 'windwp/nvim-autopairs'
Plug 'theniceboy/pair-maker.vim'
Plug 'kevinhwang91/nvim-hlslens'
" Plug 'karb94/neoscroll.nvim'
" Bookmarks
Plug 'MattesGroeger/vim-bookmarks'
" Windows management
Plug 'sindrets/winshift.nvim'
" Code Context
Plug 'wellle/context.vim'
" Other visual enhancement
Plug 'hiphish/rainbow-delimiters.nvim'
Plug 'ryanoasis/vim-devicons'
Plug 'azabiong/vim-highlighter'
"
"
" Other useful utilities
Plug 'lambdalisue/suda.vim' " :SudaWrite to write as root
Plug 'yimingwangdell/vim-translator' " ty to translate
Plug 'akinsho/toggleterm.nvim', {'tag' : '*'} " open terminal in vim
call plug#end()
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
" colorscheme tokyonight-moon
colorscheme gruvbox
" colorscheme kanagawa-dragon
set background=dark
" set background=light
" ==================codeium===================
let g:codeium_no_map_tab = v:true
let g:codeium_workspace_root_hints = ['.bzr','.git','.hg','.svn','_FOSSIL_','package.json']
imap <script><silent><nowait><expr> <C-o> codeium#Accept()
imap <C-c> <Cmd>call codeium#CycleCompletions(1)<CR>
imap <C-z> <Cmd>call codeium#Clear()<CR>
if !empty(glob('~/dellcodeium.vim'))
source ~/dellcodeium.vim
endif
highlight CodeiumSuggestion guifg=#555555 ctermfg=8
highlight link GitSignsCurrentLineBlame DiffAdd
" ==================chatgpt===================
lua <<EOF
require("chatgpt").setup({
openai_params = {
-- NOTE: model can be a function returning the model name
-- this is useful if you want to change the model on the fly
-- using commands
-- Example:
-- model = function()
-- if some_condition() then
-- return "gpt-4-1106-preview"
-- else
-- return "gpt-3.5-turbo"
-- end
-- end,
model = "gpt-3.5-turbo",
frequency_penalty = 0,
presence_penalty = 0,
max_tokens = 4095,
temperature = 0.2,
top_p = 0.1,
n = 1,
}
})
EOF
nnoremap <leader>gpt :ChatGPT<CR>
" nnoremap <leader>gpt :Codeium Chat<CR>
" === codecompanion ===
" lua << EOF
" require("codecompanion").setup()
" EOF
" ============== lualine =============
lua << EOF
local gps = require("nvim-gps")
require('lualine').setup(
{
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 10,
winbar = 1000,
}
},
sections = {
lualine_a = {},
lualine_b = {{'branch', fmt = function(str) return str:sub(1,20) end}, 'diff',},
lualine_c = { {'filename', path = 0, }},
lualine_x = {{gps.get_location, cond = gps.is_available, color="WildMenu"}},
lualine_y = {},
lualine_z = {'filesize', 'progress', 'encoding', 'fileformat'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {{'branch', }, 'diff',},
lualine_c = { {'filename', path = 0,}},
lualine_x = {},
lualine_x = {{gps.get_location, cond = gps.is_available, color="Folded"}},
lualine_y = { },
lualine_z = {'progress', 'encoding', 'fileformat'}
},
tabline = {
lualine_a = {{'filename', path=3, shorting_target=15}},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = { 'diagnostics'}},
winbar = {},
inactive_winbar = {},
extensions = {}
}
)
EOF
lua<<EOF
require("blink.cmp").setup(
{
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
-- 'super-tab' for mappings similar to vscode (tab to accept)
-- 'enter' for enter to accept
-- 'none' for no mappings
--
-- All presets have the following mappings:
-- C-space: Open menu or open docs if already open
-- C-n/C-p or Up/Down: Select next/previous item
-- C-e: Hide menu
-- C-k: Toggle signature help (if signature.enabled = true)
--
-- See :h blink-cmp-config-keymap for defining your own keymap
signature = { enabled = true,
trigger = {
enabled = false,
-- Show the signature help window after typing any of alphanumerics, `-` or `_`
show_on_keyword = true,
blocked_trigger_characters = {},
blocked_retrigger_characters = {},
-- Show the signature help window after typing a trigger character
show_on_trigger_character = true,
-- Show the signature help window when entering insert mode
show_on_insert = true,
-- Show the signature help window when the cursor comes after a trigger character when entering insert mode
show_on_insert_on_trigger_character = true,
},
},
keymap = {
preset = "none",
['<Tab>'] = {function(cmp)
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
if (cmp.snippet_active()) then
if (cmp.is_menu_visible()) then
return cmp.select_next()
else
return cmp.hide()
end
else
if (cmp.is_menu_visible()) then
return cmp.select_next()
else
if (col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil) then
cmp.show({providers = { 'lsp', 'path', 'snippets', 'buffer' }})
cmp.show_documentation()
return
else
return '\t'
end
end
end
end, 'snippet_forward'},
['<S-Tab>'] = { function(cmp)
if (cmp.is_menu_visible()) then
return cmp.select_prev()
end
end, 'snippet_backward', },
['<C-k>'] = { 'show_signature'},
['<C-space>'] = { function(cmp)
cmp.show({providers = { 'lsp', 'path', 'snippets', 'buffer' }})
end, 'show_documentation', 'hide_documentation'},
['<Enter>'] = { 'select_and_accept', 'fallback_to_mappings' },
['<C-k>'] = { 'show_signature', 'hide_signature', 'fallback' },
['<C-e>'] = { 'hide', 'fallback' },
['<C-p>'] = { 'select_prev', 'fallback_to_mappings' },
['<C-n>'] = { 'select_next', 'fallback_to_mappings' },
},
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = 'mono'
},
-- (Default) Only show the documentation popup when manually triggered
completion = {
trigger = {
prefetch_on_insert = false,
show_on_backspace_after_accept = false,
show_on_backspace_after_insert_enter = false,
show_on_backspace_after_accept = false,
show_on_keyword = true,
show_on_trigger_character = false,
show_on_blocked_trigger_characters = {' ', '\n', '\t'},
show_on_accept_on_trigger_character = false,
show_on_insert_on_trigger_character = false,
},
accept = {
-- experimental auto-brackets support
auto_brackets = {
enabled = true,
},
},
menu = {
draw = {
treesitter = { "lsp" },
},
},
documentation = {
auto_show = true,
auto_show_delay_ms = 200,
},
},
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = { 'buffer', 'snippets', 'path' },
providers = {
buffer = {
module = 'blink.cmp.sources.buffer',
score_offset = -3,
opts = {
-- default to all visible buffers
get_bufnrs = function()
return vim
.iter(vim.api.nvim_list_wins())
:map(function(win) return vim.api.nvim_win_get_buf(win) end)
:filter(function(buf) return vim.bo[buf].buftype ~= 'nofile' end)
:totable()
end,
-- buffers when searching with `/` or `?`
get_search_bufnrs = function() return { vim.api.nvim_get_current_buf() } end,
-- Maximum total number of characters (in an individual buffer) for which buffer completion runs synchronously. Above this, asynchronous processing is used.
max_sync_buffer_size = 400000,
-- Maximum total number of characters (in an individual buffer) for which buffer completion runs asynchronously. Above this, the buffer will be skipped.
max_async_buffer_size = 4000000,
-- Maximum text size across all buffers (default: 500KB)
max_total_buffer_size = 10000000,
-- Order in which buffers are retained for completion, up to the max total size limit (see above)
retention_order = { 'focused', 'visible', 'recency', 'largest' },
-- Cache words for each buffer which increases memory usage but drastically reduces cpu usage. Memory usage depends on the size of the buffers from `get_bufnrs`. For 100k items, it will use ~20MBs of memory. Invalidated and refreshed whenever the buffer content is modified.
use_cache = true,
-- Whether to enable buffer source in substitute (:s), global (:g) and grep commands (:grep, :vimgrep, etc.).
-- Note: Enabling this option will temporarily disable Neovim's 'inccommand' feature
-- while editing Ex commands, due to a known redraw issue (see neovim/neovim#9783).
-- This means you will lose live substitution previews when using :s, :smagic, or :snomagic
-- while buffer completions are active.
enable_in_ex_commands = false,
}
},
},
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "lua" }
}
)
EOF
lua<<EOF
-- Set up lspconfig.
local capabilities = require('blink.cmp').get_lsp_capabilities()
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['pylsp'].setup {
capabilities = capabilities,
}
require('lspconfig')['bashls'].setup {
capabilities = capabilities,
}
require('lspconfig')['clangd'].setup {
capabilities = capabilities,
}
require('lspconfig')['jsonls'].setup {
capabilities = capabilities,
}
require('lspconfig')['lemminx'].setup {
capabilities = capabilities,
}
require('lspconfig')['yamlls'].setup {
capabilities = capabilities,
}
require('lspconfig')['lua_ls'].setup {
capabilities = capabilities,
}
EOF
"
"=== lsp_signature ===
"
"lua<<EOF
" require "lsp_signature".setup()
"EOF
" === mason ===
lua<<EOF
require("mason").setup()
EOF
" === trouble ===
lua<<EOF
require("trouble").setup()
EOF
nnoremap <leader>dd :Trouble diagnostics toggle filter.buf=0<CR>
nnoremap <leader>gr :Trouble lsp toggle focus=false<CR>
" === aerial ===
" <leader>tg to show Outline (tags)
lua <<EOF
require("aerial").setup({
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
backends = { "treesitter" },
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr })
vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr })
end,
disable_max_lines = 30000,
layout={
min_width = 60
}
})
vim.keymap.set("n", "<leader>tg", "<cmd>AerialToggle!<CR><c-w>l")
vim.keymap.set("n", "<leader>nv", "<cmd>AerialNavToggle<CR>")
EOF
" === treesitter ===
lua <<EOF
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the listed parsers MUST always be installed)
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<leader><enter>", -- set to `false` to disable one of the mappings
node_incremental = "<leader><enter>",
scope_incremental = false,
node_decremental = false,
},
},
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (or "all")
ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
disable = { "c", "rust"},
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 1000 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- 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,
},
}
EOF
lua <<EOF
require'treesitter-context'.setup{
enable = false, -- Enable this plugin (Can be enabled/disabled later via commands)
throttle = true, -- Throttles plugin updates (may improve performance)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
-- For all filetypes
-- Note that setting an entry here replaces all other patterns for this entry.
-- By setting the 'default' entry below, you can control which nodes you want to
-- appear in the context window.
default = {
'class',
'function',
'method',
'for', -- These won't appear in the context
'while',
'if',
'switch',
'case',
},
-- Example for a specific filetype.
-- If a pattern is missing, *open a PR* so everyone can benefit.
-- rust = {
-- 'impl_item',
-- },
},
exact_patterns = {
-- Example for a specific filetype with Lua patterns
-- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
-- exactly match "impl_item" only)
-- rust = true,
}
}
EOF
lua <<EOF
require'nvim-treesitter.configs'.setup {
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",
-- You can optionally set descriptions to the mappings (used in the desc parameter of
-- nvim_buf_set_keymap) which plugins like which-key display
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
-- You can also use captures from other query groups like `locals.scm`
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
},
-- You can choose the select mode (default is charwise 'v')
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * method: eg 'v' or 'o'
-- and should return the mode ('v', 'V', or '<c-v>') or a table
-- mapping query_strings to modes.
selection_modes = {
['@parameter.outer'] = 'v', -- charwise
['@function.outer'] = 'v', -- linewise
['@class.outer'] = 'v', -- blockwise
},
-- If you set this to `true` (default is `false`) then any textobject is
-- extended to include preceding or succeeding whitespace. Succeeding
-- whitespace has priority in order to act similarly to eg the built-in
-- `ap`.
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * selection_mode: eg 'v'
-- and should return true of false
include_surrounding_whitespace = false,
},
},
}
EOF
lua <<EOF
require("nvim-gps").setup()
EOF
" === nvim-jdtls ===
" ===
" === vim-instant-markdown
" ===
let g:instant_markdown_slow = 0
let g:instant_markdown_autostart = 0
" let g:instant_markdown_open_to_the_world = 1
" let g:instant_markdown_allow_unsafe_content = 1
" let g:instant_markdown_allow_external_content = 0
" let g:instant_markdown_mathjax = 1
let g:instant_markdown_autoscroll = 1
let g:instant_markdown_browser = "google-chrome-stable --new-window"
nnoremap <c-p> :silent! InstantMarkdownStop<CR> :InstantMarkdownPreview<CR>
" ===
" ===
" === vim-table-mode
noremap <LEADER>tb :TableModeToggle<CR>
let g:table_mode_disable_mappings = 1
let g:table_mode_cell_text_object_i_map = 'k<Bar>'
" === vimwiki ====
nnoremap <leader>ww :VimwikiTabIndex<CR>
" ===
" === orgmode
" cit change state
lua << EOF
require('orgmode').setup({