-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
1161 lines (919 loc) · 30.6 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
vim9script
# Profile # {{{
# 1. Enable following profile commands (`profile start ...`)
# 2. Do something you are concerned with
# 3. Disable and finish profiling by `:profile pause | noautocmd qall!`
# 4. Check ~/tmp/vim-profile.log
# profile start ~/tmp/vim-profile.log
# profile func *
# profile file *
# }}}
# ----------------------------------------------
# Initialize # {{{
# Set initial variables/options # {{{
const my_config_dirpath = $"{$XDG_CONFIG_HOME}/vim"
&runtimepath ..= $",{my_config_dirpath}"
&runtimepath ..= $",{my_config_dirpath}/after"
g:mapleader = ","
const use_editorconfig = filereadable(".editorconfig")
# }}}
# }}}
import autoload "kg8m/plugin.vim"
import autoload "kg8m/util.vim"
# ----------------------------------------------
# Plugins # {{{
# Default plugins # {{{
plugin.DisableDefaults()
# }}}
# Initialize plugin manager # {{{
plugin.InitManager()
# }}}
# Plugins list and settings # {{{
# Watching
plugin.Register("Shougo/dpp.vim", { if: false })
# Completion, LSP # {{{
if plugin.Register("prabirshrestha/asyncomplete.vim")
import autoload "kg8m/plugin/asyncomplete.vim"
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
hook_source: () => asyncomplete.OnSource(),
hook_post_source: () => asyncomplete.OnPostSource(),
})
endif
if plugin.Register("prabirshrestha/asyncomplete-buffer.vim")
import autoload "kg8m/plugin/asyncomplete/buffer.vim" as asyncompleteBuffer
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
hook_post_source: () => asyncompleteBuffer.OnPostSource(),
})
endif
if plugin.Register("prabirshrestha/asyncomplete-file.vim")
import autoload "kg8m/plugin/asyncomplete/file.vim" as asyncompleteFile
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
hook_post_source: () => asyncompleteFile.OnPostSource(),
})
endif
if plugin.Register("kg8m/asyncomplete-mocword.vim")
import autoload "kg8m/plugin/asyncomplete/mocword.vim" as asyncompleteMocword
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
hook_post_source: () => asyncompleteMocword.OnPostSource(),
})
endif
if plugin.Register("prabirshrestha/asyncomplete-neosnippet.vim")
import autoload "kg8m/plugin/asyncomplete/neosnippet.vim" as asyncompleteNeosnippet
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
hook_post_source: () => asyncompleteNeosnippet.OnPostSource(),
})
endif
if plugin.Register("prabirshrestha/asyncomplete-lsp.vim")
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
})
endif
if plugin.Register("kitagry/asyncomplete-tabnine.vim", { if: util.IsTabnineAvailable(), build: "./install.sh" })
import autoload "kg8m/plugin/asyncomplete/tabnine.vim" as asyncompleteTabnine
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
hook_post_source: () => asyncompleteTabnine.OnPostSource(),
})
endif
if plugin.Register("prabirshrestha/asyncomplete-tags.vim")
import autoload "kg8m/plugin/asyncomplete/tags.vim" as asyncompleteTags
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
depends: ["asyncomplete.vim"],
hook_post_source: () => asyncompleteTags.OnPostSource(),
})
endif
if plugin.Register("github/copilot.vim")
import autoload "kg8m/plugin/copilot.vim"
plugin.Configure({
lazy: true,
on_cmd: ["Copilot"],
on_event: ["InsertEnter"],
on_start: true,
hook_source: () => copilot.OnSource(),
hook_post_source: () => copilot.OnPostSource(),
})
endif
if plugin.Register("prabirshrestha/vim-lsp")
import autoload "kg8m/plugin/lsp.vim"
import autoload "kg8m/plugin/lsp/servers.vim" as lspServers
lspServers.Register()
plugin.Configure({
lazy: true,
on_ft: lspServers.Filetypes(),
hook_source: () => lsp.OnSource(),
})
# Watching
plugin.Register("mattn/vim-lsp-settings", { if: false })
plugin.Register("tsuyoshicho/vim-efm-langserver-settings", { if: false })
endif
if plugin.Register("Shougo/neosnippet.vim")
import autoload "kg8m/plugin/neosnippet.vim"
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
# for Syntaxes
on_ft: ["snippet", "neosnippet"],
on_start: true,
hook_source: () => neosnippet.OnSource(),
hook_post_source: () => neosnippet.OnPostSource(),
})
endif
if plugin.Register("hrsh7th/vim-vsnip")
import autoload "kg8m/plugin/vsnip.vim"
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
hook_post_source: () => vsnip.OnPostSource(),
})
if plugin.Register("hrsh7th/vim-vsnip-integ")
plugin.Configure({
lazy: true,
on_source: ["vim-vsnip"],
})
endif
endif
# }}}
# Watching
plugin.Register("dense-analysis/ale", { if: false })
plugin.Register("pearofducks/ansible-vim")
# Show diff in Git’s interactive rebase
plugin.Register("hotwatermorning/auto-git-diff", { if: util.IsGitRebase() })
if plugin.Register("FooSoft/vim-argwrap")
import autoload "kg8m/plugin/argwrap.vim"
nnoremap <Leader>a :ArgWrap<CR>
plugin.Configure({
lazy: true,
on_cmd: ["ArgWrap"],
hook_source: () => argwrap.OnSource(),
})
endif
if plugin.Register("haya14busa/vim-asterisk")
import autoload "kg8m/plugin/asterisk.vim"
map <expr> * asterisk.WithNotify("<Plug>(asterisk-z*)")
map <expr> # asterisk.WithNotify("<Plug>(asterisk-z#)")
map <expr> g* asterisk.WithNotify("<Plug>(asterisk-gz*)")
map <expr> g# asterisk.WithNotify("<Plug>(asterisk-gz#)")
plugin.Configure({
lazy: true,
on_map: { nx: "<Plug>(asterisk-" },
})
endif
# Watching
plugin.Register("saccarosium/awesome-vim9", { if: false })
plugin.Register("h1mesuke/vim-benchmark")
if plugin.Register("kat0h/bufpreview.vim")
g:bufpreview_browser = "vivaldi"
plugin.Configure({
lazy: true,
on_cmd: ["PreviewMarkdown"],
depends: ["denops.vim"],
build: "deno task prepare",
})
endif
if plugin.Register("tyru/caw.vim")
import autoload "kg8m/plugin/caw.vim"
map <expr> gc caw.Run()
plugin.Configure({
lazy: true,
hook_source: () => caw.OnSource(),
})
endif
if plugin.Register("jkramer/vim-checkbox")
import autoload "kg8m/plugin/checkbox.vim"
augroup vimrc-plugin-checkbox
autocmd!
autocmd FileType markdown,moin noremap <buffer><silent> ch :call <SID>checkbox.Run()<CR>
augroup END
plugin.Configure({
lazy: true,
})
endif
if plugin.Register("alvan/vim-closetag")
import autoload "kg8m/plugin/closetag.vim"
plugin.Configure({
lazy: true,
on_ft: closetag.FILETYPES,
hook_source: () => closetag.OnSource(),
hook_post_source: () => closetag.OnPostSource(),
})
endif
if plugin.Register("rhysd/conflict-marker.vim")
import autoload "kg8m/plugin/conflict_marker.vim" as conflictMarker
augroup vimrc-plugin-conflict_marker
autocmd!
autocmd FileType * conflictMarker.SetupBuffer()
autocmd User all_on_start_plugins_sourced conflictMarker.NotifyActivated()
augroup END
plugin.Configure({
lazy: true,
on_map: { n: "<Plug>(conflict-marker-" },
hook_source: () => conflictMarker.OnSource(),
})
endif
if plugin.Register("Shougo/context_filetype.vim")
import autoload "kg8m/configure/filetypes/javascript.vim" as jsConfig
const for_js = [
{ start: '\<html`$', end: '\v^\s*%(//|/?\*)?\s*`', filetype: "html" },
{ start: '\<css`$', end: '\v^\s*%(//|/?\*)?\s*`', filetype: "css" },
{ start: '\v<styled%(\(.+\)|\.\w+)`$', end: '\v^\s*%(//|/?\*)?\s*`', filetype: "css" },
]
# For caw.vim and so on
g:context_filetype#filetypes = {}
for filetype in jsConfig.JS_FILETYPES + jsConfig.TS_FILETYPES
g:context_filetype#filetypes[filetype] = for_js
endfor
endif
plugin.Register("hail2u/vim-css3-syntax")
plugin.Register("Milly/deno-protocol.vim")
if plugin.Register("vim-denops/denops.vim")
g:denops_disable_version_check = true
if $DENOPS_DEBUG ==# "1"
g:denops#debug = true
g:denops#trace = true
endif
plugin.Configure({
# denops.vim is sourced when a plugin depending on denops.vim is sourced via the `depends` option.
lazy: true,
hook_post_source: () => {
# Interrupt the process of plugins via <C-c>
noremap <silent> <C-c> <Cmd>call denops#interrupt()<CR><C-c>
inoremap <silent> <C-c> <Cmd>call denops#interrupt()<CR><C-c>
cnoremap <silent> <C-c> <Cmd>call denops#interrupt()<CR><C-c>
},
})
endif
if plugin.Register("kg8m/vim-detect-indent", { if: !use_editorconfig })
g:detect_indent#detect_once = false
g:detect_indent#ignore_filetypes = ["", "gitcommit", "startify"]
# Don’t include `nofile` because a buffer generated by dps-ghosttext.vim has `nofile` buftype.
g:detect_indent#ignore_buftypes = ["quickfix", "terminal"]
plugin.Configure({
# Don’t load lazily because keystrokes are snatched on its load.
lazy: false,
depends: ["denops.vim"],
})
endif
if plugin.Register("gamoutatsumi/dps-ghosttext.vim", { if: $USE_GHOST_TEXT ==# "1" })
import autoload "kg8m/plugin/ghosttext.vim"
plugin.Configure({
lazy: true,
on_cmd: ["GhostStart"],
depends: ["denops.vim"],
hook_source: () => ghosttext.OnSource(),
})
endif
if plugin.Register("spolu/dwm.vim")
import autoload "kg8m/plugin/dwm.vim"
nnoremap <C-w>n :call DWM_New()<CR>
nnoremap <C-w><Space> :call DWM_AutoEnter()<CR>
plugin.Configure({
lazy: true,
on_cmd: ["DWMOpen"],
on_func: ["DWM_New", "DWM_AutoEnter", "DWM_Stack"],
hook_source: () => dwm.OnSource(),
hook_post_source: () => dwm.OnPostSource(),
})
endif
if plugin.Register("editorconfig/editorconfig-vim", { if: use_editorconfig })
g:EditorConfig_preserve_formatoptions = true
endif
if plugin.Register("wsdjeg/vim-fetch")
augroup vimrc-plugin-fetch
autocmd!
autocmd VimEnter * {
# Disable vim-fetch’s `gF` mappings because it conflicts with other plugins
nmap gF <Plug>(gf-user-gF)
xmap gF <Plug>(gf-user-gF)
}
augroup END
endif
if plugin.Register("junegunn/fzf.vim")
import autoload "kg8m/plugin/fzf.vim"
import autoload "kg8m/plugin/fzf/files.vim" as fzfFiles
import autoload "kg8m/plugin/fzf/git_files.vim" as fzfGitFiles
import autoload "kg8m/plugin/fzf/buffers.vim" as fzfBuffers
import autoload "kg8m/plugin/fzf/buffer_lines.vim" as fzfBufferLines
import autoload "kg8m/plugin/fzf/marks.vim" as fzfMarks
import autoload "kg8m/plugin/fzf/history.vim" as fzfHistory
import autoload "kg8m/plugin/fzf/helptags.vim" as fzfHelptags
import autoload "kg8m/plugin/fzf/yank_history.vim" as fzfYankHistory
import autoload "kg8m/plugin/fzf/grep.vim" as fzfGrep
import autoload "kg8m/plugin/fzf/shortcuts.vim" as fzfShortcuts
import autoload "kg8m/plugin/fzf/jumplist.vim" as fzfJumplist
import autoload "kg8m/plugin/fzf/rails.vim" as fzfRails
import autoload "kg8m/plugin/fzf/rails_routes.vim" as fzfRailsRoutes
import autoload "kg8m/plugin/fzf_tjump.vim" as fzfTjump
# See also vim-fzf-tjump’s mappings
nnoremap <silent> <Leader><Leader>f <ScriptCmd>fzfFiles.Run()<CR>
nnoremap <silent> <Leader><Leader>v <ScriptCmd>fzfGitFiles.Run()<CR>
nnoremap <silent> <Leader><Leader>b <ScriptCmd>fzfBuffers.Run()<CR>
nnoremap <silent> <Leader><Leader>l <ScriptCmd>fzfBufferLines.Run()<CR>
nnoremap <silent> <Leader><Leader>m <ScriptCmd>fzfMarks.Run()<CR>
nnoremap <silent> <Leader><Leader>h <ScriptCmd>fzfHistory.Run()<CR>
nnoremap <silent> <Leader><Leader>H <ScriptCmd>fzfHelptags.Run()<CR>
nnoremap <silent> <Leader><Leader>y <ScriptCmd>fzfYankHistory.Run()<CR>
nnoremap <silent> <Leader><Leader>g <ScriptCmd>fzfGrep.EnterCommand()<CR>
xnoremap <silent> <Leader><Leader>g "zy<ScriptCmd>fzfGrep.EnterCommand(@z)<CR>
xnoremap <silent> <Leader><Leader>G "zy<ScriptCmd>fzfGrep.EnterCommand(@z, { word_boundary: true })<CR>
noremap <silent> <Leader><Leader>s <ScriptCmd>fzfShortcuts.Run("")<CR>
noremap <silent> <Leader><Leader>a <ScriptCmd>fzfShortcuts.Run("SimpleAlign ")<CR>
nnoremap <silent> <Leader><Leader>[ <ScriptCmd>fzfJumplist.Back()<CR>
nnoremap <silent> <Leader><Leader>] <ScriptCmd>fzfJumplist.Forward()<CR>
nnoremap <silent> <Leader><Leader>r <ScriptCmd>fzfRails.EnterCommand()<CR>
nnoremap <silent> <Leader><Leader>R <ScriptCmd>fzfRailsRoutes.Run()<CR>
plugin.Configure({
lazy: true,
on_start: true,
depends: ["fzf"],
hook_source: () => fzf.OnSource(),
})
# Add to runtimepath (and use its Vim scripts) but don’t use its binary.
# Use fzf binary already installed instead.
plugin.Register("junegunn/fzf", { lazy: true })
if plugin.Register("kg8m/vim-fzf-tjump")
nnoremap <Leader><Leader>t :FzfTjump<Space>
xnoremap <Leader><Leader>t "zy:FzfTjump<Space><C-r>z
map g] <Plug>(fzf-tjump)
plugin.Configure({
lazy: true,
on_cmd: ["FzfTjump"],
on_map: { nx: "<Plug>(fzf-tjump)" },
depends: ["fzf.vim", "vim-parallel-auto-ctags"],
hook_source: () => fzfTjump.OnSource(),
})
endif
endif
plugin.Register("thinca/vim-ft-diff_fold")
plugin.Register("thinca/vim-ft-help_fold")
if plugin.Register("muz/vim-gemfile")
import autoload "kg8m/plugin/gemfile.vim"
augroup vimrc-plugin-gemfile
autocmd!
autocmd FileType Gemfile runtime! ftplugin/ruby.vim indent/ruby.vim
augroup END
endif
if plugin.Register("kana/vim-gf-user")
gf#user#extend("kg8m#plugin#gf_user#VimAutoload", 1000)
if util.OnRailsDir()
gf#user#extend("kg8m#plugin#gf_user#RailsFiles", 1000)
endif
endif
if plugin.Register("lambdalisue/vim-gin")
g:gin_diff_default_args = ["++processor=delta"]
augroup vimrc-plugin-gin
autocmd!
# Regular `gf` doesn’t work due to some reason.
autocmd FileType gin-diff nnoremap <buffer> gf :execute "edit" expand("<cfile>")<CR>
augroup END
plugin.Configure({
lazy: true,
on_cmd: ["GinDiff", "GinEdit", "GinPatch"],
depends: ["denops.vim"],
})
endif
if plugin.Register("tpope/vim-git", { if: util.IsGitCommit() })
augroup vimrc-plugin-git
autocmd!
# Prevent vim-git from change options, e.g., formatoptions
autocmd FileType gitcommit b:did_ftplugin = true
augroup END
endif
plugin.Register("tpope/vim-haml")
if plugin.Register("tweekmonster/helpful.vim")
plugin.Configure({
lazy: true,
on_cmd: ["HelpfulVersion"],
})
endif
if plugin.Register("itchyny/vim-histexclude")
import autoload "kg8m/plugin/histexclude.vim"
nnoremap <expr> : histexclude.Run()
plugin.Configure({
lazy: true,
hook_source: () => histexclude.OnSource(),
})
endif
if plugin.Register("obcat/vim-hitspop")
import autoload "kg8m/plugin/hitspop.vim"
plugin.Configure({
lazy: true,
on_start: true,
hook_source: () => hitspop.OnSource(),
})
endif
if plugin.Register("jonsmithers/vim-html-template-literals")
g:htl_css_templates = true
g:htl_all_templates = false
plugin.Configure({
depends: ["vim-javascript"],
})
plugin.Register("pangloss/vim-javascript")
endif
if plugin.Register("[email protected]:kg8m/vim-hz_ja-extracted")
plugin.Configure({
lazy: true,
on_cmd: ["Hankaku", "HzjaConvert", "Zenkaku"],
hook_source: () => {
g:hz_ja_extracted_default_commands = true
g:hz_ja_extracted_default_mappings = false
},
})
endif
if plugin.Register("Yggdroot/indentLine")
import autoload "kg8m/plugin/indent_line.vim" as indentLine
plugin.Configure({
lazy: true,
on_start: true,
hook_source: () => indentLine.OnSource(),
})
endif
# Text object for (Japanese) sentence: s
if plugin.Register("deton/jasentence.vim")
plugin.Configure({
lazy: true,
on_map: { nv: ["(", ")"], o: "s" },
hook_source: () => {
g:jasentence_endpat = '[。.?!!?]\+'
},
})
endif
if plugin.Register("othree/javascript-libraries-syntax.vim")
g:used_javascript_libs = "jquery,react,vue"
endif
if plugin.Register("fuenor/JpFormat.vim")
import autoload "kg8m/plugin/jpformat.vim"
plugin.Configure({
lazy: true,
on_map: { x: "gq" },
hook_source: () => jpformat.OnSource(),
})
endif
plugin.Register("bfrg/vim-jq")
if plugin.Register("elzr/vim-json")
g:vim_json_syntax_conceal = false
endif
plugin.Register("MaxMEllon/vim-jsx-pretty")
if plugin.Register("lambdalisue/vim-kensaku")
plugin.Configure({
# vim-kensaku is sourced when `.config/vim/autoload/kg8m/util/f2.vim` is sourced.
# The `f2.vim` is sourced when my `f2` mapping is triggered.
# cf. .config/vim/autoload/kg8m/configure/mappings.vim
lazy: true,
depends: ["denops.vim"],
})
endif
if plugin.Register("cohama/lexima.vim")
import autoload "kg8m/plugin/lexima.vim"
plugin.Configure({
lazy: true,
on_event: ["InsertEnter"],
on_start: true,
hook_source: () => lexima.OnSource(),
hook_post_source: () => lexima.OnPostSource(),
})
endif
if plugin.Register("itchyny/lightline.vim")
import autoload "kg8m/plugin/lightline.vim"
plugin.Configure({
lazy: true,
on_start: true,
hook_source: () => lightline.OnSource(),
hook_post_source: () => lightline.OnPostSource(),
})
endif
if plugin.Register("AndrewRadev/linediff.vim")
plugin.Configure({
lazy: true,
on_cmd: ["Linediff"],
hook_source: () => {
g:linediff_second_buffer_command = "rightbelow vertical new"
},
})
endif
if plugin.Register("andymass/vim-matchup")
import autoload "kg8m/plugin/matchup.vim"
plugin.Configure({
lazy: true,
on_start: true,
hook_source: () => matchup.OnSource(),
})
endif
plugin.Register("kg8m/moin.vim")
if plugin.Register("mattn/vim-molder")
import autoload "kg8m/plugin/molder.vim"
nnoremap <silent> <Leader>e <ScriptCmd>molder.Run()<CR>
plugin.Configure({
lazy: true,
on_start: true,
hook_source: () => molder.OnSource(),
})
endif
if plugin.Register("lambdalisue/vim-mr")
import autoload "kg8m/plugin/mr.vim"
g:mr_mrw_disabled = true
g:mr_mrr_disabled = true
g:mr_mrd_disabled = true
g:mr#threshold = 10'000
g:mr#mru#filename = $"{$XDG_DATA_HOME}/vim/mr/mru"
g:mr#mru#predicates = [(filepath) => mr.Predicate(filepath)]
endif
plugin.Register("lambdalisue/vim-nerdfont")
if plugin.Register("tyru/open-browser.vim")
import autoload "kg8m/plugin/open_browser.vim" as openBrowser
map <Leader>o <Plug>(openbrowser-open)
plugin.Configure({
lazy: true,
on_map: { nx: "<Plug>(openbrowser-open)" },
hook_source: () => openBrowser.OnSource(),
hook_post_source: () => openBrowser.OnPostSource(),
})
endif
if plugin.Register("tyru/open-browser-github.vim")
plugin.Configure({
lazy: true,
on_cmd: ["OpenGithubFile"],
depends: ["open-browser.vim"],
hook_post_source: () => {
# I don’t need these commands.
delcommand OpenGithubCommit
delcommand OpenGithubIssue
delcommand OpenGithubProject
delcommand OpenGithubPullReq
},
})
endif
if plugin.Register("tyru/operator-camelize.vim")
xmap <Leader>C <Plug>(operator-camelize)
xmap <Leader>c <Plug>(operator-decamelize)
plugin.Configure({
lazy: true,
on_map: { x: ["<Plug>(operator-camelize)", "<Plug>(operator-decamelize)"] },
})
endif
plugin.Register("kana/vim-operator-user")
if plugin.Register("kg8m/vim-parallel-auto-ctags", { if: util.IsCtagsAvailable() && !util.IsGitTmpEdit() })
import autoload "kg8m/plugin/parallel_auto_ctags.vim" as parallelAutoCtags
plugin.Configure({
lazy: true,
on_start: true,
hook_source: () => parallelAutoCtags.OnSource(),
hook_post_source: () => parallelAutoCtags.OnPostSource(),
})
endif
if plugin.Register("thinca/vim-prettyprint")
plugin.Configure({
# Don’t load lazily because dein.vim’s `on_cmd: "PP"` doesn’t work.
lazy: false,
})
endif
if plugin.Register("lambdalisue/vim-protocol")
plugin.Configure({
lazy: true,
on_path: ['^https\?://'],
})
endif
if plugin.Register("vim-python/python-syntax")
g:python_highlight_all = true
endif
if plugin.Register("yssl/QFEnter")
import autoload "kg8m/plugin/qfenter.vim"
plugin.Configure({
lazy: true,
on_ft: ["qf"],
hook_source: () => qfenter.OnSource(),
})
endif
if plugin.Register("bfrg/vim-qf-history")
plugin.Configure({
lazy: true,
on_cmd: ["Chistory"],
})
endif
if plugin.Register("stefandtw/quickfix-reflector.vim")
plugin.Configure({
lazy: true,
on_ft: ["qf"],
})
endif
if plugin.Register("tpope/vim-rails", { if: !util.IsGitTmpEdit() && util.OnRailsDir() })
# For Rails engines.
if !filereadable("config/environment.rb")
augroup vimrc-rails
autocmd!
autocmd BufNewFile,BufRead * b:rails_root = getcwd()
augroup END
endif
if !has_key(g:, "rails_path_additions")
g:rails_path_additions = []
endif
if isdirectory("spec/support")
g:rails_path_additions += [
"spec/support",
]
endif
plugin.Configure({
# Don’t load lazily because some features don’t work.
lazy: false,
})
endif
plugin.Register("jlcrochet/vim-rbs")
plugin.Register("lambdalisue/vim-readablefold")
plugin.Register("tpope/vim-repeat")
if plugin.Register("vim-ruby/vim-ruby")
g:no_ruby_maps = true
# For performance: vim-ruby searches Ruby directories and sets the `path` option but the feature is a bit slow and
# unnecessary for me.
g:ruby_path = ""
augroup vimrc-plugin-ruby
autocmd!
# vim-ruby overwrites vim-gemfile’s filetype detection
autocmd BufEnter Gemfile set filetype=Gemfile
# Prevent vim-matchup from being wrong for Ruby’s modifier `if`/`unless`
autocmd FileType ruby unlet! b:ruby_no_expensive
augroup END
endif
if plugin.Register("joker1007/vim-ruby-heredoc-syntax")
import autoload "kg8m/plugin/ruby_heredoc_syntax.vim" as rubyHeredocSyntax
plugin.Configure({
lazy: true,
on_ft: ["ruby"],
hook_source: () => rubyHeredocSyntax.OnSource(),
})
endif
# Text object for surrounded by a bracket-pair or same characters: S + {user input}
if plugin.Register("machakann/vim-sandwich")
import autoload "kg8m/plugin/sandwich.vim"
import autoload "kg8m/util/matchpairs.vim"
xnoremap <Leader>sa <Plug>(operator-sandwich-add)
# Operators for deleting/replacing using textobjects that automatically detect matching pairs where some same type
# symbols are mixed up:
#
# *----------- ( --------*
# *----------- ) --------*
# *---- ( -----------------------------------------*
# *---- " ---*
# *---------------------- " -----------------------------------*
# aaaaa"bbbbb(ccccc(ddddd(eeeee“ffffffffff”eeeee)ddddd)ccccc)bbbbb"aaaaa
nnoremap <expr> <Leader>sd sandwich.OperatorDeleteExpr()
nnoremap <expr> <Leader>sr sandwich.OperatorReplaceExpr()
# Textobjects that automatically detect matching pairs where some same type symbols are mixed up:
#
# <--------- i( ------->
# <--------- i) ------->
# <---------- a( -------->
# <- i( --------------------------->
# <- i( --------------------------------------->
# <-- i" -->
# <-------------------- i" ---------------------------------->
# aaaaa"bbbbb(ccccc(ddddd(eeeee“ffffffffff”eeeee)ddddd)ccccc)bbbbb"aaaaa
const modes = ["x", "o"]
const a_i_types = ["a", "i"]
for key in matchpairs.GroupedJapanesePairs()->keys()
for key_or_another in matchpairs.KeyPairFor(key)
for mode in modes
for a_or_i in a_i_types
const lhs = $"{a_or_i}{key_or_another}"
const rhs = $"sandwich.AutoTextobjExpr({string(key_or_another)}, '{mode}', '{a_or_i}')"
execute $"{mode}noremap <expr><silent> {lhs} {rhs}"
endfor
endfor
endfor
endfor
nmap . <Plug>(operator-sandwich-dot)
plugin.Configure({
lazy: true,
on_map: { nx: "<Plug>(operator-sandwich-", o: "<Plug>(textobj-sandwich-" },
hook_source: () => sandwich.OnSource(),
hook_post_source: () => sandwich.OnPostSource(),
})
endif
if plugin.Register("vim-scripts/sequence")
map <Leader>+ <Plug>SequenceV_Increment
map <Leader>- <Plug>SequenceV_Decrement
plugin.Configure({
lazy: true,
on_map: { x: "<Plug>Sequence" },
})
endif
plugin.Register("lunacookies/vim-sh")
# Legacy Vim script version for my development.
if plugin.Register("kg8m/vim-simple-align", { name: "vim-simple-align-legacy", if: false })
xnoremap <Leader>a :SimpleAlign<Space>
endif
if plugin.Register("kg8m/vim-simple-align", { rev: "vim9" })
xnoremap <Leader>a :SimpleAlign<Space>
endif
# Don’t use slim-template/vim-slim because it has some bugs.
# For example, highlighting is broken with quoteless attribute like `span(class=detect_span_class)`.
plugin.Register("delphaber/vim-slim")
if plugin.Register("AndrewRadev/splitjoin.vim")
nnoremap <Leader>J :SplitjoinJoin<CR>
nnoremap <Leader>S :SplitjoinSplit<CR>
plugin.Configure({
lazy: true,
on_cmd: ["SplitjoinJoin", "SplitjoinSplit"],
hook_source: () => {
g:splitjoin_split_mapping = ""
g:splitjoin_join_mapping = ""
g:splitjoin_ruby_trailing_comma = true
g:splitjoin_ruby_hanging_args = false
},
})
endif
if plugin.Register("monkoose/vim9-stargate")
g:stargate_chars = "FKLASDHGUIONMREWCVTYBX,;J"
nnoremap <C-w>f :call stargate#Galaxy()<CR>
endif
if plugin.Register("mhinz/vim-startify", { if: !util.IsGitTmpEdit() })
import autoload "kg8m/plugin/startify.vim"
if argc() ># 0
# `on_event: "BufWritePre"` for `SaveSession()`: Load startify before writing buffer (on `BufWritePre`) and
# register autocmd for `BufWritePost`
plugin.Configure({
lazy: true,
on_cmd: ["Startify"],
on_event: ["BufWritePre"],
hook_source: () => startify.OnSource(),
hook_post_source: () => startify.OnPostSource(),
})
else
startify.Setup()
endif
endif
if plugin.Register("zhimsel/vim-stay", { if: !util.IsGitCommit() })
import autoload "kg8m/configure/folding/manual.vim" as manualFolding
set viewoptions=cursor,folds
augroup vimrc-plugin-stay
autocmd!
autocmd User BufStaySavePre manualFolding.Restore()
augroup END
endif
if plugin.Register("lambdalisue/vim-suda")
plugin.Configure({
lazy: true,
on_cmd: ["SudaRead"],
})
endif
plugin.Register("hashivim/vim-terraform")
if plugin.Register("vim-test/vim-test")
import autoload "kg8m/plugin/test.vim"
nnoremap <Leader>T :write<CR><ScriptCmd>test.RunFileTest()<CR>
nnoremap <Leader>t :write<CR><ScriptCmd>test.RunNearestTest()<CR>
plugin.Configure({
lazy: true,
on_cmd: ["TestFile", "TestNearest"],
hook_source: () => test.OnSource(),
})
endif