-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginal_init.vim
2559 lines (2338 loc) · 92 KB
/
original_init.vim
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
" Last Modified Date: 2023.04.24
" Desc : NEOVIM 0.10.0(support Python, Lua)
" __
" __ ____ __ __ __ /\_\ ___ ___ ____ ____
" | \/ \ \ / / /\ \/\ \\/\ \ /'' __` _`\ | _ \ / ___|
" | |\/| |\ V / \ \ \_/ |\ \ \/\ \/\ \/\ \ | |_) | |
" | | | | | | \ \___/ \ \_\ \_\ \_\ \_\| _ <| |___
" |_| |_| |_| \/__/ \/_/\/_/\/_/\/_/|_| \_\\____|
" ========================================================
" {{{ Lazy.nvim
lua << EOF
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
--vim
{
"mg979/vim-visual-multi",
lazy = true,
keys = {
{ "<C-n>", mode = { "n", "x" }, desc = "visual multi" },
},
},
{ "mbbill/undotree", cmd = "UndotreeToggle" },
{
"dstein64/vim-startuptime",
cmd = "StartupTime",
init = function()
vim.g.startuptime_tries = 10
vim.keymap.set("n", "<F12>", ":StartupTime<CR>", { silent = true })
end,
},
{
"arecarn/vim-crunch",
keys = { "<Plug>(crunch-operator-line)","<Plug>(visual-crunch-operator)" },
},
{ "terryma/vim-expand-region", keys = { "v", "<C-v>" } },
{ "AndrewRadev/linediff.vim", cmd = {"Linediff", "LinediffAdd"} },
{ "alpertuna/vim-header", cmd = "AddHeader" },
{ "iqxd/vim-mine-sweeping", cmd = "MineSweep" },
{ "Yggdroot/LeaderF", cmd = { "LeaderfFile", "Leaderf", "LeaderfLine" } },
{ "voldikss/vim-floaterm", cmd = { "FloatermNew", "FloatermSend" } },
{ "iamcco/markdown-preview.nvim", ft = "markdown" },
{ "plasticboy/vim-markdown", ft = "markdown" },
{ "dhruvasagar/vim-table-mode", ft = {"markdown", "org"} },
{ "mhinz/vim-startify" },
{ "zef/vim-cycle" },
{ "wellle/targets.vim", keys = { "c", "d", "y", "v"} },
{ "chrisbra/csv.vim", ft = "csv" },
{ "ntpeters/vim-better-whitespace",event = "InsertEnter" },
{ "lfv89/vim-interestingwords", event = "VeryLazy" },
{ "markonm/traces.vim", event = "CmdlineEnter" },
{ "triglav/vim-visual-increment", event = "VeryLazy" },
{ "itchyny/vim-cursorword", event = { "BufEnter", "BufNewFile", "VeryLazy" } },
{ "bronson/vim-visual-star-search" },
--lua
{ "alvarosevilla95/luatab.nvim" },
{ "lukas-reineke/indent-blankline.nvim", event = "BufRead" },
{ "kevinhwang91/nvim-hlslens" },
{
"chentoast/marks.nvim",
keys = "m" ,
config = function()
require'marks'.setup {
default_mappings = false,
builtin_marks = { ".", "<", ">", "^" },
cyclic = true,
force_write_shada = false,
refresh_interval = 250,
sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 },
excluded_filetypes = {},
bookmark_0 = {
sign = "⚑",
virt_text = "hello world"
},
mappings = {
delete_buf = "mc",
toggle = "mm",
prev = false -- pass false to disable only this default mapping
}
}
end,
},
{
"windwp/nvim-autopairs",
event = "InsertEnter",
config = function()
require("nvim-autopairs").setup {}
local disable_filetype = { "TelescopePrompt" }
local disable_in_macro = false -- disable when recording or executing a macro
local disable_in_visualblock = false -- disable when insert after visual block mode
local ignored_next_char = [=[[%w%%%'%[%"%.]]=]
local enable_moveright = true
local enable_afterquote = true -- add bracket pairs after quote
local enable_check_bracket_line = true --- check bracket in same line
local enable_bracket_in_quote = true --
local break_undo = true -- switch for basic rule break undo sequence
local check_ts = false
local map_cr = true
local map_bs = true -- map the <BS> key
local map_c_h = false -- Map the <C-h> key to delete a pair
local map_c_w = false -- map <c-w> to delete a pair if possible
end,
},
{ "karb94/neoscroll.nvim" },
{ "petertriho/nvim-scrollbar", event = "VimEnter" },
{ "folke/which-key.nvim", lazy = true },
{
"b3nj5m1n/kommentary",
event = "VimEnter",
config = function()
require("kommentary")
end,
},
{
"kyazdani42/nvim-tree.lua",
branch = "master",
commit = "9914780",
dependencies = {
"kyazdani42/nvim-web-devicons",
branch = "master",
commit = "9697285",
},
},
{
"ellisonleao/weather.nvim",
cmd = "Weather",
config = function()
require("weather").setup({
city = "Xi'an",
win_height = 10,
win_width = 50,
})
end,
},
{ "Vonr/align.nvim", event = "VeryLazy" },
{ "kylechui/nvim-surround",
keys = {
{ mode = "n", "ys" },
{ mode = "n", "cs" },
{ mode = "n", "ds" },
{ mode = "i", "<C-g>" },
{ mode = "x", "S" },
}, --S, dss, css
config = function()
require("nvim-surround").setup()
end,
},
--motion
{
"ggandor/leap.nvim",
keys = {"r", "R", "gr"},
config = function()
require('leap').opts.highlight_unlabeled_phase_one_targets = true
vim.keymap.set({'x', 'o', 'n'}, 'r', '<Plug>(leap-forward-to)')
vim.keymap.set({'x', 'o', 'n'}, 'R', '<Plug>(leap-backward-to)')
vim.keymap.set({'x', 'o', 'n'}, 'gr', '<Plug>(leap-cross-window)')
end,
},
{
"ggandor/flit.nvim",
keys = {"f", "F", "t", "T"},
config = function()
require('flit').setup {
keys = { f = 'f', F = 'F', t = 't', T = 'T' },
labeled_modes = "v",
multiline = true,
opts = {}
}
end,
},
--colorscheme
{ "EdenEast/nightfox.nvim" },
{ "folke/tokyonight.nvim", event = "CursorHold" },
--Telescope
{
"nvim-telescope/telescope.nvim",
cmd = { "Telescope" },
dependencies = {
{
"nvim-telescope/telescope-file-browser.nvim",
config =function()
require("telescope").load_extension "file_browser"
end,
},
{ "nvim-lua/plenary.nvim" },
},
config = function()
require("telescope").setup {
defaults = {
initial_mode = 'normal',
prompt_prefix = " ",
selection_caret = " ",
path_display = { "smart" },
dynamic_preview_title = true,
},
pickers = {
find_files = {
hidden = true,
--find_command = { "fd", "f" },
find_command = { "rg", "--files" },
mappings = {
n = {
["cd"] = function(prompt_bufnr)
local selection = require("telescope.actions.state").get_selected_entry()
local dir = vim.fn.fnamemodify(selection.path, ":p:h")
require("telescope.actions").close(prompt_bufnr)
-- Depending on what you want put `cd`, `lcd`, `tcd`
vim.cmd(string.format("silent lcd %s", dir))
end
}
}
},
},
extensions = {
file_browser = {
theme = "ivy",
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
},
},
}
end,
},
--notes
{
"nvim-orgmode/orgmode",
ft = "org",
config = function()
local orgmode = require('orgmode')
orgmode.setup_ts_grammar()
orgmode.setup({
org_agenda_files = {'C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/Org/**'},
org_default_notes_file = 'C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/Org/index.org',
org_hide_leading_stars = true,
org_hide_emphasis_markers = true,
org_todo_keywords = { 'TODO(t)', 'WAITING', 'IN-PROGRESS', '|', 'DONE(d)', 'CANCELLED' },
org_todo_keyword_faces = {
['TODO'] = ':background cyan :foreground black',
['WAITING'] = ':background darkyellow :foreground black',
['IN-PROGRESS'] = ':background coral :foreground black',
['DONE'] = ':background chartreuse :foreground black',
['CANCELLED'] = ':background red :foreground black',
}
})
end,
},
{
"akinsho/org-bullets.nvim",
ft = "org",
config = function()
require('org-bullets').setup({
show_current_line = false,
concealcursor = true,
indent = true,
symbols = {
list = "•",
headlines = {"◉", "◎", "○", "✺", "▶", "⤷" }, --neorg level1:◉⦿
--headlines = { "◉", "○", "✸", "✿" }, --orgmode
--headlines = {"🌸","🌱","💧","✨","💗" }, --others
checkboxes = {
cancelled = { '', 'OrgCancelled' },
half = { '', 'OrgTSCheckboxHalfChecked' },
done = { '', 'OrgDone' },--✓
todo = { '', 'OrgTODO' },--×
},
},
})
end,
},
--treesitter
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = "BufRead",
},
{ "HiPhish/nvim-ts-rainbow2" },
--cmp
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "hrsh7th/cmp-cmdline" },
{ "hrsh7th/cmp-emoji" },
{ "hrsh7th/cmp-calc" },
{ "mstanciu552/cmp-matlab" },
{ "saadparwaiz1/cmp_luasnip" },
{ "lukas-reineke/cmp-under-comparator" },
{
"uga-rosa/cmp-dictionary",
branch = "main",
commit = "93f3e2c",
},
{ "ray-x/cmp-treesitter" },
{
"tzachar/cmp-tabnine",
build = "powershell ./install.ps1",
},
{ "onsails/lspkind.nvim",
branch = "master",
commit = "c68b3a0",
},
--lsp,
{
"williamboman/mason.nvim", build = ":MasonUpdate",
dependencies = {
"williamboman/mason-lspconfig.nvim",
},
},
{ "neovim/nvim-lspconfig", event = "BufRead" },
{
"ray-x/lsp_signature.nvim",
event = "InsertEnter",
config = function()
require'lsp_signature'.setup(cfg) -- no need to specify bufnr if you don't use toggle_key
require'lsp_signature'.on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key
end,
},
--Snippets,
{ "L3MON4D3/LuaSnip",
event = "InsertEnter",
config = function()
require("luasnip/loaders/from_vscode").lazy_load({ paths = {"C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/friendly-snippets"}})
end,
},
--Local plugins
{ dir = "C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/Local_Plugins/vim-speeddating-master", ft = {"markdown", "org"} }, --modified
{ dir = "C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/Local_Plugins/lualine.nvim-master", event = "VimEnter" }, --modified
{
dir = "C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/Local_Plugins/weather3day.nvim-main", --modified
cmd = "Weather3day",
init = function()
vim.g.weather_city = "Xi'an"--weather3day plug
end,
},
})
EOF
" }}}
" {{{ 编码格式
if has('multi_byte')
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,gbk,gb18030,big5,ucs-bom,euc-jp,latin1
endif
" 解决vim编辑matlab文件保存后, matlab中文为乱码的问题
augroup matlab_filetype
autocmd!
autocmd FileType matlab set fileencoding=cp936
augroup END
" }}}
" {{{ 字体/字号
if exists('g:neovide')
" set guifont=Delugia\ Mono:h15.5 " Nerd Font (Cascadia Code)
set guifont=Delugia\ Mono:h11.6 " Nerd Font (Cascadia Code)
" set guifont=CodeNewRoman\ NFM:h12 " Nerd Font
" set guifont=OperatorMono\ NF:h12 " Nerd Font
" set guifont=ComicMono\ NF:h12 " Nerd Font
set guifontwide=inconsolatago\ qihei\ nf:h12.5 " 中文 Nerd Font
else
set guifont=Delugia\ Mono:h12.1 " Nerd Font (Cascadia Code)
" set guifont=CodeNewRoman\ NFM:h12 " Nerd Font
" set guifont=OperatorMono\ NF:h12 " Nerd Font
" set guifont=ComicMono\ NF:h12 " Nerd Font
set guifontwide=inconsolatago\ qihei\ nf:h12.5 " 中文 Nerd Font
endif
" }}}
" {{{ 常规设置
" 高亮
syntax enable " 打开语法高亮
syntax on " 开启文件类型侦测
syntax sync minlines=64
if &bg == 'dark'
hi CursorLine gui=NONE guibg=#3C4452
elseif &bg == 'light'
hi CursorLine gui=NONE guibg=#c6cbd9
endif
language en
language messages zh_CN.utf-8 " 解决consle提示信息输出乱码
filetype on " 侦测文件类型
filetype indent on " 针对不同的文件类型采用不同的缩进格式
filetype plugin on " 针对不同的文件类型加载对应的插件
filetype plugin indent on
set autoindent " 自动对齐
set tabstop=4 " 设置tab键的宽度
set softtabstop=4 " 退格键的长度
set expandtab " 在输入tab后,vim用个空格来填充这个tab
set lazyredraw " 延时绘制(提升性能)
set shortmess-=S
" set wildmode=list:longest,full " Command <Tab> completion, list matches
set wildmode=longest,full " Command <Tab> completion, list matches
set wildmenu " enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ " stuff to ignore when tab completing
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
set laststatus=2 " 开启状态栏信息
set cmdheight=1 " 命令行的高度,默认为1,这里设为2
set linebreak " 整词换行
set backspace=2 " 设置退格键可用
set backspace=indent,eol,start
set shiftwidth=4 " 换行时行间交错使用4个空格
set cindent shiftwidth=4 " 自动缩进4空格
set smartindent " 智能自动缩进
set ai! " 设置自动缩进
set nu! " 显示行号
set showmatch " 显示括号配对情况
set mouse=a " 启用鼠标
set ruler " 右下角显示光标位置的状态行
set hlsearch " 开启高亮显示结果
set incsearch " 开启实时搜索功能
set ignorecase " 忽略大小写
set smartcase
" set nowrapscan " 搜索到文件两端时不重新搜索
set vb t_vb= " 关闭提示音
set guicursor+=a:blinkon0 " 设置光标不闪烁
set hidden " 允许在有未保存的修改时切换缓冲区
set winaltkeys=no " 设置 alt 键不映射到菜单栏
set scrolloff=5 " 设置目标行与顶部底部的距离(5行)
set writebackup " 设置无备份文件
set nobackup
set autochdir " 设定文件浏览器目录为当前目录
set wrap " 设置一行太长,自动换行
" set norelativenumber " 不显示相对行号
set relativenumber " 显示相对行号
set showcmd
set formatoptions+=m " 如遇Unicode值大于255的文本,不必等到空格再折行
set formatoptions+=B " 合并两行中文时,不在中间加空格
set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界
set magic " For regular expressions turn magic on
" Fold
set foldmethod=marker " 折叠类型---对文中标志折叠
" set foldmethod=manual " 折叠类型---手工
" set foldmethod=syntax " 折叠类型---语法高亮
" set foldmethod=indent " 折叠类型---缩进
set foldcolumn=2 " 显示折叠标志
set foldlevel=33
" set foldcolumn& " 去掉折叠标志
" 分屏设置
set splitright " 新的窗口在右边打开
set splitbelow " 新的窗口在下边打开
" set listchars=tab:\|\ , " 显示Tab符,使用一高亮竖线代替
set listchars=trail:.,extends:>,precedes:<,space:. " 将空格用.表示
" set listchars=eol:¬,tab:>·,trail:.,extends:>,precedes:<,space:␣ " <F3>为显示空格的开关
" IOS:Windows 设置 clipboard 提高Nvim启动速率
set clipboard+=unnamed " 公用剪切板
let g:clipboard = {
\ 'name': 'win32yank',
\ 'copy': {
\ '+': 'win32yank.exe -i --crlf',
\ '*': 'win32yank.exe -i --crlf',
\ },
\ 'paste': {
\ '+': 'win32yank.exe -o --lf',
\ '*': 'win32yank.exe -o --lf',
\ },
\ 'cache_enabled': 0,
\ }
" ENV-Python
let g:python_host_prog = "C:/Python/Python311/python.exe"
let g:python3_host_prog = "C:/Python/Python311/python.exe"
let $PYTHONUNBUFFERED=1 " 禁用python stdout缓冲
augroup python_related
autocmd!
autocmd BufNewFile,BufRead *.py set fileformat=unix " 以unix格式存储文件,避免在推送到GITHUB或分享给其他用户时出现文件转换问题.
autocmd BufNewFile,BufRead *.rpy set syntax=python
augroup END
" 禁止屏闪和铃声
augroup genconfiggroup
autocmd!
autocmd GUIEnter * set vb t_vb=
autocmd VimEnter * set vb t_vb=
augroup END
augroup tex_md_width
autocmd!
autocmd FileType tex set textwidth=72 " 文本超过一定长度时自动换行
autocmd FileType markdown set textwidth=80 " 文本超过一定长度时自动换行
augroup END
augroup line_font
autocmd!
" 高亮加下划线显示每行第80个字符
au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim,*.md 2match Underlined /.\%81v/
" Fortran语言,高亮加下划线显示每行第72个字符(遵循Fortran77固定格式)
au BufRead,BufNewFile *.for 2match Underlined /.\%73v/
augroup END
" Return to last edit position when opening files (You want this!)
lua << EOF
vim.cmd([[ autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]])
EOF
" 当剩余的窗口都不是文件编辑窗口时,自动退出vim
augroup Buffer_quit
autocmd!
autocmd BufEnter * if 0 == len(filter(range(1, winnr('$')), 'empty(getbufvar(winbufnr(v:val), "&bt"))')) | qa! | endif
augroup END
" Highlihgt yank
set background=light " 放到这里的目的,为了tokyonight-day显示复制颜色(HighlightedyankRegion)
highlight HighlightedyankRegion ctermbg=237 guibg=#c34043
augroup highlight_yank
autocmd!
au TextYankPost * silent! lua vim.highlight.on_yank{higroup="HighlightedyankRegion", timeout=120}
augroup END
" }}}
" {{{ 中/英输入法切换
augroup input_switching
autocmd!
autocmd VimEnter * :silent :!C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/im-select.exe 1033
" autocmd InsertEnter * :silent :!C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/im-select.exe 2052
autocmd InsertLeave * :silent :!C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/im-select.exe 1033
autocmd VimLeave * :silent :!C:/Users/ThinkPad/AppData/Local/nvim-data/Maxl/im-select.exe 1033
augroup END
" }}}
" {{{ mapping
map ; :
noremap s <nop>
xmap s <nop>
nnoremap <Space> <nop>
nnoremap , <nop>
let g:mapleader = "\<Space>"
let g:maplocalleader = ","
" 显示list 用.表示空格
nnoremap <F3> :set list!<CR>
inoremap <F3> <C-o>:set list!<CR>
cnoremap <F3> <C-c>:set list!<CR>
" 高亮光标行列
nnoremap <silent> <F4> :set cuc! cul!<CR>
" x,c仅复制,不更改寄存器.(ps: d为剪切)
nnoremap x "_x
vnoremap x "_x
nnoremap c "_c
vnoremap c "_c
nnoremap Y y$
vnoremap p pgvy
vnoremap P Pgvy
" 单词的 选/改/删
nnoremap <silent> vi viw
nnoremap <silent> ci ciw
nnoremap <silent> di diw
" IDE like delete
inoremap <C-BS> <Esc>b"_dei
" 取消高亮
nnoremap <silent> <BS> :nohl<CR>
" Open Startify
nnoremap <silent> <leader>st :Startify<CR>
" 比较line
nnoremap <leader>dt :Linediff<CR>
" 插入时间
iab xtime <c-r>=strftime("20%y-%m-%d %a %H:%M")<CR>
iab xdate <c-r>=strftime("20%y-%m-%d (%a)")<CR>
" 代码折叠
nnoremap <silent> <Tab> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" zf --创建折叠,仅在manual/marker中有效(eg:v{motion}zf v{motion}指Shift+v)
" zd --删除折叠,仅在manual/marker中有效
" zD --删除嵌套折叠,仅在manual/marker中有效
" za --打开/关闭当前折叠
" zM --关闭所有折叠
" zR --打开所有折叠
" vimrc
nnoremap <silent> <leader>rc :edit $MYVIMRC<cr>
nnoremap <silent> <leader>rr :source $MYVIMRC<CR>
" spell checking
nnoremap <Leader>sc :set spell!<CR>
nnoremap <leader>sn ]s
nnoremap <leader>sp [s
nnoremap <leader>sa zg
" 显示单词拼写建议
nnoremap <leader>s? z=
" 光标移动
inoremap <m-h> <Left>
inoremap <m-j> <Down>
inoremap <m-k> <Up>
inoremap <m-l> <Right>
" INSERT Mode下使用光标移动一个单词
inoremap <C-h> <C-Left>
inoremap <C-l> <C-Right>
" ----------------- find and replace --------------
nnoremap <leader>z :%s/\<<C-R>=expand("<cword>")<CR>\>/<C-R>=expand("<cword>")<CR>/g<left><left>
vnoremap <leader>z :s///g<left><left><left>
" ----------------- make a list --------------
nnoremap <leader>b :put =range(,,1)<left><left><left><left>
" ----------------- Indentation -------------------
nnoremap < <<
nnoremap > >>
"---------------- 分屏快捷键设置 ----------------
nnoremap <silent> sh :set splitright<CR>:vsplit<CR>
nnoremap <silent> sj :set splitbelow<CR>:split<CR>
nnoremap <silent> st :set splitright<CR>:vsplit<CR>:Startify<CR>
" 互换分割窗口.Rotate screens
nnoremap <S-h> <C-w>b<C-w>H
" nnoremap srh <C-w>b<C-w>K
" 光标移动
nnoremap <C-l> <C-W><C-L>
nnoremap <C-h> <C-W><C-H>
"nnoremap <C-j> <C-W><C-J>
"nnoremap <C-k> <C-W><C-K>
" terminal 分屏窗口移动,split navigations,smart way to move between windows
tnoremap <C-h> <C-w><C-h>
tnoremap <C-j> <C-w><C-j>
tnoremap <C-k> <C-w><C-k>
tnoremap <C-l> <C-w><C-l>
"---------------- 调整分屏尺寸 ----------------
nnoremap <silent> <C-up> :resize -3<CR>
nnoremap <silent> <C-down> :resize +3<CR>
nnoremap <silent> <C-left> :vertical resize +3<CR>
nnoremap <silent> <C-right> :vertical resize -3<CR>
" ----------- 支持Alt+n切换标签页 -----------
:nn <M-1> 1gt
:nn <M-2> 2gt
:nn <M-3> 3gt
:nn <M-4> 4gt
:nn <M-5> 5gt
:nn <M-6> 6gt
:nn <M-7> 7gt
:nn <M-8> 8gt
:nn <M-9> 9gt
:nn <M-0> :tablast<CR>
" Alt+左右键来移动标签顺序
nn <silent> <M-left> :if tabpagenr() == 1\|exe "tabm ".tabpagenr("$")\|el\|exe "tabm ".(tabpagenr()-2)\|en<CR>
nn <silent> <M-right> :if tabpagenr() == tabpagenr("$")\|tabm 0\|el\|exe "tabm ".tabpagenr()\|en<CR>
" 修改标签页的标题
set guitablabel=%{GuiTabLabel()}
function! GuiTabLabel()
let label = ''
let bufnrlist = tabpagebuflist(v:lnum)
for bufnr in bufnrlist
if getbufvar(bufnr, "&modified")
let label = '+'
break
endif
endfor
let label .= v:lnum.': '
let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
if name == ''
if &buftype=='quickfix'
let name = '[Quickfix List]'
else
let name = '[No Name]'
endif
else
let name = fnamemodify(name,":t")
endif
let label .= name
let wincount = tabpagewinnr(v:lnum, '$')
return label
endfunction
" -------------------- Buffer ---------------------
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
"------------- Command Mode related ---------------
" Bash like keys for the command line
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
" cnoremap <C-K> <C-U>
cnoremap <C-h> <C-Left>
cnoremap <C-l> <C-Right>
cnoremap <m-h> <left>
cnoremap <m-l> <right>
cnoremap <m-j> <down>
cnoremap <m-k> <up>
cnoremap <C-j> <down>
cnoremap <C-k> <up>
" 在命令行粘贴的快捷键
cnoremap <C-V> <C-R>+
" $q is super useful when browsing on the command line
" it deletes everything until the last slash
" NORMAL Mode, Q --进入到Ex命令行模式
cno $q <C-\>eDeleteTillSlash()<CR>
function! DeleteTillSlash()
let g:cmd = getcmdline()
if has("win16") || has("win32")
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
endif
if g:cmd == g:cmd_edited
if has("win16") || has("win32")
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
endif
endif
return g:cmd_edited
endfunc
" }}}
" {{{ Colorscheme << nightfox >>
lua << EOF
require('nightfox').setup({
options = {
compile_path = vim.fn.stdpath("cache") .. "/nightfox",
compile_file_suffix = "_compiled", -- Compiled file suffix
transparent = false, -- Disable setting background
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
dim_inactive = false, -- Non focused panes set to alternative background
styles = { -- Style to be applied to different syntax groups
comments = "NONE", -- Value is any valid attr-list value `:help attr-list`
conditionals = "italic",
constants = "NONE",
operators = "NONE",
strings = "NONE",
types = "italic,bold",
variables = "NONE",
functions = "italic",
keywords = "bold",
numbers = "italic",
},
inverse = {
match_paren = true,
visual = false, --default is true
search = false,
},
modules = {
nvimtree = true,
cmp = true,
telescope = true,
treesitter = true,
whichkey = true,
},
},
groups = {
all = {
NormalFloat = { bg = "bg1" },
NormalNC = { bg = "NONE" },
},
},
})
--note: nightfox color change: (1) white: #dfdfe0 -> #abb2bf ps:白色变浅
-- (2) fg1: #cdcecf -> #abb2bf ps:白色变浅,同上
-- (3) comment: #738091 -> #5c6370 ps:注释颜色变浅
-- (4) sel0: #2b3b51 -> #3e4452 ps:V模式框选颜色变深
-- file: "C:\Users\ThinkPad\AppData\Local\nvim-data\lazy\nightfox.nvim\lua\nightfox\palette\nightfox.lua"
local palettes = {
nightfox = {
white = "#abb2bf",
fg1 = "#b2b2b2",
comment = "#5c6370",
sel0 = "#364a82", --visual
sel1 = "#228b22", --visual Selected
},
duskfox = {
white = "#abb2bf",
fg1 = "#b2b2b2",
comment = "#5c6370",
sel0 = "#364a82", --visual
sel1 = "#228b22", --visual Selected
},
terafox = {
white = "#abb2bf",
fg1 = "#b2b2b2",
comment = "#5c6370",
sel0 = "#364a82", --visual
sel1 = "#228b22", --visual Selected
},
nordfox = {
white = "#abb2bf",
fg1 = "#b2b2b2",
comment = "#5c6370",
sel0 = "#364a82", --visual
sel1 = "#228b22", --visual Selected
},
carbonfox = {
white = "#abb2bf",
fg1 = "#b2b2b2",
comment = "#5c6370",
sel0 = "#364a82", --visual
sel1 = "#228b22", --visual Selected
},
dayfox = {
bg1 = "#e1e2e7",
fg1 = "#4d688e",
fg3 = "#a8aecb", --line number
sel0 = "#99a7df", --visual
orange = "#b15c00", --number
},
}
require("nightfox").setup({ palettes = palettes })
--Dark: nightfox duskfox terafox nordfox Carbonfox
--Light: dayfox dawnfox
--vim.cmd("colorscheme nightfox")
--vim.cmd("colorscheme dayfox")
EOF
" }}}
" {{{ Colorscheme << tokyonight >>
lua << EOF
require("tokyonight").setup({
style = "storm", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day`
light_style = "day", -- The theme is used when the background is set to light
transparent = false, -- Enable this to disable setting the background color
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim
styles = {
comments = { italic = false },
keywords = { bold = true },
functions = { italic = true },
variables = { },
-- Background styles. Can be "dark", "transparent" or "normal"
sidebars = "dark", -- style for sidebars, see below
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
dim_inactive = false, -- dims inactive windows
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold
on_colors = function(colors) end,
on_highlights = function(highlights, colors) end,
})
EOF
" colorscheme tokyonight-night tokyonight-storm tokyonight-moon
" }}}
" {{{ Random colorscheme
lua << EOF
random_color = {
-- 'tokyonight-day',
-- 'dayfox',
'duskfox',
'terafox',
'nordfox',
'nightfox',
'nightfox',
'nightfox',
'nightfox',
'nightfox',
}
math.randomseed(os.time())
local mycolor = random_color[math.random(table.getn(random_color))]
vim.cmd('colorscheme ' .. mycolor)
EOF
" }}}
" {{{ Highlihgt Diff
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=bold guifg=bg guibg=#87af87 " 新增的行
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=bold guifg=bg guibg=#86abdc " 删除的行
highlight DiffChange cterm=none ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=#8787af " 变化的行
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=bold guifg=bg guibg=#f7768e " 变化的文字
" }}}
" ------------------------------- Plugins Config --------------------------------
" {{{ << Plugin - markonm/traces.vim >>
let g:traces_normal_preview = 1
let g:traces_num_range_preview = 1
" }}}
" {{{ Compiler code & Python & REPL & Matlab & Fortran << floaterm && REPL >>
hi FloatermBorder guibg=#3e4452 guifg=#5c6370
let g:floaterm_autoclose=0
let g:floaterm_keymap_kill = '<C-q>'
let g:floaterm_keymap_next = '<leader>tn'
nnoremap <leader>to :FloatermNew<CR>
nnoremap <leader>tt :FloatermToggle<CR>
tnoremap <Esc> <C-\><C-n>
" tnoremap <leader>tt <C-\><C-n>:FloatermToggle<CR>
" SumatraPdf open pdf
nnoremap <A-o> :FloatermNew SumatraPdf <C-r><C-l><CR>
" TOOl rg
nnoremap <leader>tr :FloatermNew<CR>rg.exe<Space>
augroup Compiler_code
autocmd!
autocmd FileType floaterm nnoremap <buffer> <Esc> :q<CR>
" -- Python --
autocmd FileType python nnoremap <C-CR> :FloatermNew py "%:p"<CR>
autocmd FileType python noremap! <C-CR> <Esc>:FloatermToggle<CR>
" autocmd FileType python tnoremap <C-CR> <C-\><C-n>:FloatermToggle<CR>
" -- Python REPL --
nnoremap <leader>tp :FloatermNew --width=0.5 --wintype=vsplit --name=repl --position=rightbelow ipython<CR>
autocmd FileType python nnoremap <leader>w :FloatermSend<CR>
autocmd FileType python vnoremap <leader>w :FloatermSend<CR>
" -- Matlab --
autocmd FileType matlab nnoremap <silent><C-CR> :! matlab -nosplash -nodesktop -r %:r<CR><CR>
" TERMINAL运行matlab代码,以'test.m'代码为例 'matlab -nosplash -nodesktop -r test'
" -- Fortran --
autocmd FileType fortran nnoremap <C-CR> :FloatermNew<CR>compilervars.bat intel64<CR>ifort<Space>
" -- Typst --
" highligth file 'D:\Program Files\Neovim\share\nvim\runtime\syntax\typst.vim'
autocmd BufRead,BufNewFile *.typ setlocal filetype=typst
autocmd FileType typst nnoremap <C-CR> :FloatermNew --height=1.0 typst watch %:p<CR>
autocmd FileType typst command! TypstPDF execute "FloatermNew! sumatrapdf %:p<C-h><C-h><C-h>pdf<CR>"
augroup END