-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.lua
1631 lines (1617 loc) · 51.1 KB
/
init.lua
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
-- MiniDeps auto download setup
local path_package = vim.fn.stdpath("data") .. "/site/"
local mini_path = path_package .. "pack/deps/opt/mini.nvim"
if not vim.uv.fs_stat(mini_path) then
vim.cmd('echo "Installing `mini.nvim`" | redraw')
local clone_cmd = {
"git",
"clone",
"--filter=blob:none",
"https://github.com/echasnovski/mini.nvim",
mini_path,
}
vim.fn.system(clone_cmd)
vim.cmd('echo "Installed `mini.nvim`" | redraw')
end
-- Add mini.nvim to runtime
vim.cmd("packadd mini.nvim | helptags ALL")
-- Setup MiniDeps
require("mini.deps").setup({ path = { package = path_package } })
-- Export add, now and later functions from MiniDeps
local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later
-- Track and update self
add("echasnovski/mini.nvim")
-- Globals variables and functions declared and used
now(function()
Global = {
-- Lsp capabilities used
lspCapabilities = vim.lsp.protocol.make_client_capabilities(),
floatMultiplier = 0.8,
-- Space and tab characters to use
leadSpace = "›",
nextSpace = " ",
leadTabSpace = "»",
palette = {
base00 = "#282C34",
base01 = "#353B45",
base02 = "#3E4451",
base03 = "#545862",
base04 = "#565C64",
base05 = "#ABB2BF",
base06 = "#B6BDCA",
base07 = "#C8CCD4",
base08 = "#E06C75",
base09 = "#D19A66",
base0A = "#E5C07B",
base0B = "#98C379",
base0C = "#56B6C2",
base0D = "#61AFEF",
base0E = "#C678DD",
base0F = "#BE5046",
},
}
-- Add document support for completion items to lspCapabilities
Global.lspCapabilities.textDocument.completion.completionItem.resolveSupport = Global.lspCapabilities.textDocument.completion.completionItem.resolveSupport
or {}
Global.lspCapabilities.textDocument.completion.completionItem.resolveSupport.properties = {
"documentation",
"detail",
}
-- Function to set leadmultispace correctly
Global.leadMultiTabSpace = Global.leadTabSpace .. Global.nextSpace
Global.leadMultiSpace = Global.leadSpace .. Global.nextSpace
Global.leadMultiSpaceCalc = function()
vim.opt_local.listchars:remove("leadmultispace")
vim.opt_local.listchars:append({
leadmultispace = Global.leadSpace .. string.rep(Global.nextSpace, (vim.bo.shiftwidth - 1)),
})
end
-- Mapping functions to map keys
Tmap = function(suffix, rhs, desc, opts)
opts = opts or {}
opts.silent = true
opts.desc = desc
vim.keymap.set("t", suffix, rhs, opts)
end
Nmap = function(suffix, rhs, desc, opts)
opts = opts or {}
opts.silent = true
opts.desc = desc
vim.keymap.set("n", suffix, rhs, opts)
end
Vmap = function(suffix, rhs, desc, opts)
opts = opts or {}
opts.silent = true
opts.desc = desc
vim.keymap.set("v", suffix, rhs, opts)
end
Imap = function(suffix, rhs, desc, opts)
opts = opts or {}
opts.silent = true
opts.desc = desc
vim.keymap.set("i", suffix, rhs, opts)
end
Smap = function(suffix, rhs, desc, opts)
opts = opts or {}
opts.silent = true
opts.desc = desc
vim.keymap.set("s", suffix, rhs, opts)
end
Xmap = function(suffix, rhs, desc, opts)
opts = opts or {}
opts.silent = true
opts.desc = desc
vim.keymap.set("x", suffix, rhs, opts)
end
-- Highlight function to define or change highlights
Hi = function(name, opts)
vim.api.nvim_set_hl(0, name, opts)
end
end)
-- Default settings
now(function()
-- vim.cmd("let g:python_recommended_style=0")
-- vim.o.colorcolumn = "150"
-- vim.o.relativenumber = true
vim.cmd("packadd cfilter")
vim.diagnostic.config({ virtual_text = true, underline = false, severity_sort = true })
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.g.nerd_font = true
vim.o.background = "dark"
vim.o.breakindent = true
vim.o.completeopt = "menu,menuone,noselect"
vim.o.conceallevel = 2
vim.o.cursorcolumn = false
vim.o.cursorline = true
vim.o.expandtab = true
vim.o.fillchars = [[eob: ,foldopen:,foldsep: ,foldclose:]] -- ▾,▸
vim.o.foldcolumn = "1"
vim.o.foldenable = true
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.hlsearch = true
vim.o.ignorecase = false
vim.o.incsearch = true
vim.o.laststatus = 3
vim.o.list = true
vim.o.listchars = "tab:" .. Global.leadMultiTabSpace .. ",trail:␣,extends:»,precedes:«,nbsp:⦸,eol:¬"
vim.o.maxmempattern = 10000
vim.o.mouse = "a"
vim.o.mousescroll = "ver:1,hor:1"
vim.o.number = true
vim.o.path = "**"
vim.o.pumblend = 0
vim.o.scrolloff = 999
vim.o.shiftwidth = 2
vim.o.showcmd = true
vim.o.showmatch = true
vim.o.showmode = false
vim.o.signcolumn = "yes:1"
vim.o.smartcase = false
vim.o.splitbelow = true
vim.o.splitright = true
vim.o.synmaxcol = 100
vim.o.tabstop = 2
vim.o.termguicolors = true
vim.o.textwidth = 0
vim.o.undofile = false
vim.o.updatetime = 500
vim.o.wildmenu = true
vim.o.wildmode = "longest:full,full"
vim.o.winblend = 0
vim.o.wrap = false
vim.opt.matchpairs:append("<:>")
vim.opt.wildignore:append("*.png,*.jpg,*.jpeg,*.gif,*.wav,*.dll,*.so,*.swp,*.zip,*.gz,*.svg,*.cache,*/.git/*")
end)
-- Initial UI setup
now(function()
require("mini.notify").setup({
window = {
config = {
row = 2,
border = "rounded",
},
max_width_share = 0.5,
winblend = 0,
},
})
vim.notify = MiniNotify.make_notify()
-- Function to apply colorscheme
Global.apply_colorscheme = function()
require("mini.base16").setup({
palette = Global.palette,
plugins = { default = true },
})
Hi("@tag.attribute", { link = "Statement" })
Hi("@tag.delimiter", { link = "Delimiter" })
Hi("MiniIndentscopeSymbol", { link = "SpecialKey" })
Hi("Operator", { link = "Delimiter" })
Hi("QuickFixLineNr", { link = "SpecialKey" })
end
Global.apply_colorscheme()
add("luukvbaal/statuscol.nvim")
require("statuscol").setup({
relculright = false,
bt_ignore = { "terminal", "\\[dap-repl-*\\]" },
ft_ignore = { "ministarter", "help" },
segments = {
{ text = { "%s" }, click = "v:lua.ScSa" },
{
text = { require("statuscol.builtin").lnumfunc },
click = "v:lua.ScLa",
},
{
text = { require("statuscol.builtin").foldfunc, " " },
click = "v:lua.ScFa",
},
},
})
end)
-- Mini plugins setup
now(function()
require("mini.ai").setup({
custom_textobjects = {
B = require("mini.extra").gen_ai_spec.buffer(),
D = require("mini.extra").gen_ai_spec.diagnostic(),
I = require("mini.extra").gen_ai_spec.indent(),
L = require("mini.extra").gen_ai_spec.line(),
N = require("mini.extra").gen_ai_spec.number(),
},
})
require("mini.align").setup()
require("mini.animate").setup()
require("mini.basics").setup({
options = {
extra_ui = true,
win_borders = "rounded",
},
mappings = {
windows = true,
move_with_alt = true,
},
autocommands = {
relnum_in_visual_mode = true,
},
})
require("mini.bracketed").setup()
require("mini.bufremove").setup()
require("mini.clue").setup({
triggers = {
{ mode = "c", keys = "<C-r>" },
{ mode = "i", keys = "<C-r>" },
{ mode = "i", keys = "<C-x>" },
{ mode = "n", keys = "'" },
{ mode = "n", keys = "<C-w>" },
{ mode = "n", keys = "<Leader>" },
{ mode = "n", keys = "[" },
{ mode = "n", keys = "]" },
{ mode = "n", keys = "`" },
{ mode = "n", keys = "g" },
{ mode = "n", keys = "z" },
{ mode = "n", keys = '"' },
{ mode = "n", keys = [[\]] },
{ mode = "x", keys = "'" },
{ mode = "x", keys = "<Leader>" },
{ mode = "x", keys = "[" },
{ mode = "x", keys = "]" },
{ mode = "x", keys = "`" },
{ mode = "x", keys = "g" },
{ mode = "x", keys = "z" },
{ mode = "x", keys = '"' },
},
clues = {
{
{ mode = "n", keys = "<leader>a", desc = "+Ai" },
{ mode = "n", keys = "<leader>b", desc = "+Buffer" },
{ mode = "n", keys = "<leader>c", desc = "+Clipboard" },
{ mode = "n", keys = "<leader>d", desc = "+Debug" },
{ mode = "n", keys = "<leader>e", desc = "+Explorer" },
{ mode = "n", keys = "<leader>f", desc = "+Find" },
{ mode = "n", keys = "<leader>g", desc = "+Generate" },
{ mode = "n", keys = "<leader>l", desc = "+Lsp" },
{ mode = "n", keys = "<leader>lj", desc = "+Java" },
{ mode = "n", keys = "<leader>p", desc = "+Print" },
{ mode = "n", keys = "<leader>q", desc = "+QuickFix" },
{ mode = "n", keys = "<leader>t", desc = "+Test" },
{ mode = "n", keys = "<leader>tg", desc = "+Go" },
{ mode = "n", keys = "<leader>tj", desc = "+Java" },
{ mode = "n", keys = "<leader>tp", desc = "+Python" },
{ mode = "n", keys = "<leader>v", desc = "+Visits" },
{ mode = "n", keys = "<leader>w", desc = "+Window" },
},
require("mini.clue").gen_clues.builtin_completion(),
require("mini.clue").gen_clues.g(),
require("mini.clue").gen_clues.marks(),
require("mini.clue").gen_clues.registers(),
require("mini.clue").gen_clues.windows(),
require("mini.clue").gen_clues.z(),
},
window = {
delay = 0,
config = {
border = "rounded",
},
},
})
require("mini.comment").setup()
require("mini.completion").setup({
window = {
info = { border = "rounded" },
signature = { border = "rounded" },
},
})
-- This makes completion faster by suggesting words from current buffer only
vim.cmd("set complete=.")
require("mini.cursorword").setup()
require("mini.diff").setup()
require("mini.extra").setup()
require("mini.files").setup({
windows = {
preview = true,
width_preview = 75,
},
mappings = {
go_in = "L",
go_in_plus = "l",
go_out = "H",
go_out_plus = "h",
},
options = {
permanent_delete = true,
use_as_default_explorer = true,
},
})
require("mini.git").setup()
require("mini.hipatterns").setup({
highlighters = {
fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" },
hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" },
todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" },
note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" },
hex_color = require("mini.hipatterns").gen_highlighter.hex_color(),
test = require("mini.extra").gen_highlighter.words({ "TEST" }, "MiniHipatternsNote"),
},
})
require("mini.icons").setup()
MiniIcons.mock_nvim_web_devicons()
MiniIcons.tweak_lsp_kind()
require("mini.indentscope").setup()
require("mini.jump").setup()
require("mini.jump2d").setup()
require("mini.misc").setup()
MiniMisc.setup_auto_root({
"meson.build",
"CMakeLists.txt",
"Makefile",
"go.mod",
"package.json",
"pom.xml",
"build.gradle",
".git",
})
require("mini.move").setup({
mappings = {
left = "<C-S-left>",
right = "<C-S-right>",
down = "<C-S-down>",
up = "<C-S-up>",
line_left = "<C-S-left>",
line_right = "<C-S-right>",
line_down = "<C-S-down>",
line_up = "<C-S-up>",
},
options = {
reindent_linewise = true,
},
})
require("mini.operators").setup()
require("mini.pairs").setup()
require("mini.pick").setup({
window = {
config = function()
local height = math.floor(0.6 * vim.o.lines)
local width = math.floor(0.6 * vim.o.columns)
return {
anchor = "NW",
height = height,
width = width,
row = math.floor(0.5 * (vim.o.lines - height)),
col = math.floor(0.5 * (vim.o.columns - width)),
}
end,
},
})
vim.ui.select = MiniPick.ui_select
require("mini.sessions").setup()
-- Snippets provider plugin
add("rafamadriz/friendly-snippets")
require("mini.snippets").setup({
snippets = {
require("mini.snippets").gen_loader.from_lang(),
},
})
require("mini.splitjoin").setup()
require("mini.starter").setup({
header = table.concat({
"██████╗░██████╗░░░███╗░░████████╗██████╗░░█████╗░███╗░░██╗",
"╚════██╗╚════██╗░████║░░╚══██╔══╝██╔══██╗██╔══██╗████╗░██║",
"░░███╔═╝░█████╔╝██╔██║░░░░░██║░░░██████╔╝██║░░██║██╔██╗██║",
"██╔══╝░░░╚═══██╗╚═╝██║░░░░░██║░░░██╔══██╗██║░░██║██║╚████║",
"███████╗██████╔╝███████╗░░░██║░░░██║░░██║╚█████╔╝██║░╚███║",
"╚══════╝╚═════╝░╚══════╝░░░╚═╝░░░╚═╝░░╚═╝░╚════╝░╚═╝░░╚══╝",
"",
"Pwd: " .. vim.fn.getcwd(),
}, "\n"),
query_updaters = "abcdefghijklmnopqrstuvwxyz0123456789_-.+",
items = {
require("mini.starter").sections.builtin_actions(),
require("mini.starter").sections.recent_files(3, false),
require("mini.starter").sections.recent_files(3, true),
require("mini.starter").sections.sessions(3, true),
},
footer = table.concat({
"███╗░░██╗███████╗░█████╗░██╗░░░██╗██╗███╗░░░███╗",
"████╗░██║██╔════╝██╔══██╗██║░░░██║██║████╗░████║",
"██╔██╗██║█████╗░░██║░░██║╚██╗░██╔╝██║██╔████╔██║",
"██║╚████║██╔══╝░░██║░░██║░╚████╔╝░██║██║╚██╔╝██║",
"██║░╚███║███████╗╚█████╔╝░░╚██╔╝░░██║██║░╚═╝░██║",
"╚═╝░░╚══╝╚══════╝░╚════╝░░░░╚═╝░░░╚═╝╚═╝░░░░░╚═╝",
}, "\n"),
})
require("mini.statusline").setup({
content = {
active = function()
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
local git = MiniStatusline.section_git({ trunc_width = 75 })
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
local filename = MiniStatusline.section_filename({ trunc_width = 1000 })
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 1000 })
local location = MiniStatusline.section_location({ trunc_width = 75 })
local lsp = MiniStatusline.section_lsp({ trunc_width = 75 })
local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
return MiniStatusline.combine_groups({
{ hl = mode_hl, strings = { mode } },
{ hl = "MiniStatuslineDevinfo", strings = { git, diagnostics, lsp } },
"%<",
{ hl = "MiniStatuslineFilename", strings = { filename } },
"%=",
{ hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
{ hl = mode_hl, strings = { search, location } },
})
end,
},
set_vim_settings = false,
})
require("mini.surround").setup()
require("mini.tabline").setup({
tabpage_section = "right",
})
require("mini.trailspace").setup()
require("mini.visits").setup()
end)
-- Non lazy plugins registration
now(function()
add("stevearc/quicker.nvim")
require("quicker").setup({
keys = {
{
">",
function()
require("quicker").expand({ before = 5, after = 5, add_to_existing = true })
end,
desc = "Expand quickfix context",
},
{
"<",
function()
require("quicker").collapse()
end,
desc = "Collapse quickfix context",
},
},
follow = {
enabled = true,
},
trim_leading_whitespace = "all",
})
add("neovim/nvim-lspconfig")
add({
source = "nvim-treesitter/nvim-treesitter",
hooks = {
post_checkout = function()
vim.cmd("TSUpdate")
end,
},
})
require("nvim-treesitter.configs").setup({
ensure_installed = {
"angular",
"awk",
"bash",
"bibtex",
"c",
"cmake",
"cpp",
"css",
"csv",
"diff",
"dockerfile",
"doxygen",
"fish",
"git_config",
"git_rebase",
"gitcommit",
"gitignore",
"go",
"gomod",
"gosum",
"gowork",
"graphql",
"groovy",
"html",
"http",
"hurl",
"ini",
"java",
"javascript",
"jq",
"jsdoc",
"json",
"json5",
"latex",
"lua",
"luadoc",
"make",
"markdown",
"markdown_inline",
"meson",
"ninja",
"nix",
"perl",
"php",
"pug",
"python",
"regex",
"requirements",
"ruby",
"rust",
"scala",
"scss",
"sql",
"ssh_config",
"starlark",
"svelte",
"toml",
"typescript",
"vim",
"vimdoc",
"vue",
"xml",
"yaml",
"yuck",
"zig",
},
modules = {},
sync_install = false,
auto_install = true,
ignore_install = {},
indent = {
enable = true,
-- Disable indenting if file size is greater than 2MB
disable = function(lang, buf)
local max_filesize = 2 * 1024 * 1024
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize and lang ~= "wasm" then
return true
end
end,
},
highlight = {
enable = true,
-- Disable highlighting if file size is greater than 2MB
disable = function(lang, buf)
local max_filesize = 2 * 1024 * 1024
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize and lang ~= "wasm" then
-- Match syntax for @punctuation.bracket so that all kinds of braces are highlighted even if treesitter is disabled
vim.cmd("syntax match @punctuation.bracket /[(){}\\[\\]]/")
return true
end
end,
additional_vim_regex_highlighting = false,
},
})
vim.o.foldmethod = "expr"
-- Set foldexpr to treesitter provided folds
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
add("mfussenegger/nvim-dap")
local dap = require("dap")
dap.defaults.fallback.force_external_terminal = true
dap.defaults.fallback.terminal_win_cmd = "belowright new | resize 15"
add({
source = "nvim-treesitter/nvim-treesitter-context",
depends = {
"nvim-treesitter/nvim-treesitter",
},
})
require("treesitter-context").setup({
max_lines = 6,
})
add({
source = "danymat/neogen",
depends = {
"nvim-treesitter/nvim-treesitter",
},
})
require("neogen").setup({ snippet_engine = "mini" })
add({
source = "MeanderingProgrammer/render-markdown.nvim",
depends = {
"nvim-treesitter/nvim-treesitter",
"echasnovski/mini.nvim",
},
})
require("render-markdown").setup()
add({
source = "OXY2DEV/helpview.nvim",
depends = {
"nvim-treesitter/nvim-treesitter",
"echasnovski/mini.nvim",
},
})
require("helpview").setup()
add({
source = "Wansmer/treesj",
depends = {
"nvim-treesitter/nvim-treesitter",
},
})
require("treesj").setup()
add({
source = "mfussenegger/nvim-jdtls",
depends = {
"mfussenegger/nvim-dap",
"neovim/nvim-lspconfig",
},
})
Global.jdtls_start = function()
-- Java lsp lazy loading setup
require("jdtls").start_or_attach((function()
local config = {
cmd = { "/usr/bin/jdtls" },
root_dir = require("jdtls.setup").find_root({ "mvnw", "gradlew", "pom.xml", "build.gradle", ".git" }),
settings = {
java = {
references = {
includeDecompiledSources = true,
},
eclipse = {
downloadSources = true,
},
maven = {
downloadSources = true,
},
format = {
enabled = true,
},
inlayHints = {
parameterNames = {
enabled = "all",
exclusions = { "this" },
},
},
signatureHelp = { enabled = true, description = { enabled = true } },
contentProvider = { preferred = "fernflower" },
codeGeneration = {
toString = {
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
},
useBlocks = true,
},
configuration = {
runtimes = {
{
name = "JavaSE-11",
path = "/usr/lib/jvm/java-1.11.0-openjdk-amd64/",
},
{
name = "JavaSE-17",
path = "/usr/lib/jvm/java-1.17.0-openjdk-amd64/",
},
{
name = "JavaSE-21",
path = "/usr/lib/jvm/java-1.21.0-openjdk-amd64/",
},
},
},
},
},
capabilities = Global.lspCapabilities,
}
local bundles = {
vim.fn.glob("/usr/share/java-debug/com.microsoft.java.debug.plugin.jar", true),
}
vim.list_extend(bundles, vim.split(vim.fn.glob("/usr/share/java-test/*.jar", true), "\n"))
local extendedClientCapabilities = require("jdtls").extendedClientCapabilities
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
config["init_options"] = {
bundles = bundles,
extendedClientCapabilities = extendedClientCapabilities,
}
return config
end)())
end
add({
source = "Goose97/timber.nvim",
depends = {
"nvim-treesitter/nvim-treesitter",
},
})
require("timber").setup()
end)
-- Linting and formatting setup
now(function()
add("stevearc/conform.nvim")
local conform = require("conform")
conform.setup({
formatters_by_ft = {
c = { "clang_format" },
css = { "prettier" },
fish = { "fish_indent" },
go = { "gofmt", "gofumpt", "goimports", "golines" },
groovy = { "npm-groovy-lint" },
html = { "prettier" },
java = { "google-java-format" },
javascript = { "prettier" },
json = { "jq", "prettier" },
jsonc = { "prettier" },
lua = { "stylua" },
python = { "black" },
rust = { "rustfmt" },
sh = { "shfmt" },
sql = { "sqlfluff" },
svelte = { "prettier" },
svg = { "xmllint" },
tex = { "latexindent" },
typescript = { "prettier" },
xml = { "xmllint" },
yaml = { "yamlfmt" },
},
default_format_opts = {
lsp_format = "fallback",
},
})
conform.formatters.yamlfmt = {
prepend_args = { "-formatter", "include_document_start=true,indentless_arrays=true" },
}
conform.formatters.shfmt = {
prepend_args = { "-s" },
}
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
add("mfussenegger/nvim-lint")
require("lint").linters_by_ft = {
-- lua = { "luacheck" },
-- yaml = { "yamllint" },
c = { "clangtidy" },
go = { "golangcilint" },
groovy = { "npm-groovy-lint" },
java = { "checkstyle" },
javascript = { "eslint" },
json = { "jsonlint" },
jsonc = { "jsonlint" },
python = { "pylint" },
sh = { "shellcheck" },
sql = { "sqlfluff" },
svelte = { "eslint" },
typescript = { "eslint" },
}
end)
-- Non lazy keymaps registration
now(function()
local te_buf = nil
local te_win_id = nil
local function openTerminal()
if vim.fn.bufexists(te_buf) ~= 1 then
vim.cmd("split | wincmd J | resize 10 | terminal")
te_win_id = vim.fn.win_getid()
te_buf = vim.fn.bufnr("%")
elseif vim.fn.win_gotoid(te_win_id) ~= 1 then
vim.cmd("sbuffer " .. te_buf .. "| wincmd J | resize 10")
te_win_id = vim.fn.win_getid()
end
vim.cmd("startinsert")
end
local function hideTerminal()
if vim.fn.win_gotoid(te_win_id) == 1 then
vim.cmd("hide")
end
end
local function toggleTerminal()
if vim.fn.win_gotoid(te_win_id) == 1 then
hideTerminal()
else
openTerminal()
end
end
-- Function to convert spaces to tabs
local function toggleTabs()
vim.opt.expandtab = false
vim.cmd("retab!")
end
-- Function to convert tabs to spaces
local function toggleSpaces()
vim.opt.expandtab = true
vim.cmd("retab!")
end
-- Function to toggle virtual text for diagnostics
local function diagnosticVirtualTextToggle()
vim.diagnostic.config({
virtual_text = not vim.diagnostic.config().virtual_text,
})
end
local keycode = vim.keycode or function(x)
return vim.api.nvim_replace_termcodes(x, true, true, true)
end
local keys = {
["cr"] = keycode("<CR>"),
["ctrl-y"] = keycode("<C-y>"),
["ctrl-y_cr"] = keycode("<C-y><CR>"),
}
local function crAction()
if vim.fn.pumvisible() ~= 0 then
local item_selected = vim.fn.complete_info()["selected"] ~= -1
return item_selected and keys["ctrl-y"] or keys["ctrl-y_cr"]
else
return require("mini.pairs").cr()
end
end
Global.miniPickVisits = function(cwd, desc)
local sort_latest = MiniVisits.gen_sort.default({ recency_weight = 1 })
MiniExtra.pickers.visit_paths({ cwd = cwd, filter = "core", sort = sort_latest }, { source = { name = desc } })
end
Imap("<CR>", crAction, "Enter to select in wildmenu", { expr = true })
Imap("<S-Tab>", [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]], "Cycle wildmenu anti-clockwise", { expr = true })
Imap("<Tab>", [[pumvisible() ? "\<C-n>" : "\<Tab>"]], "Cycle wildmenu clockwise", { expr = true })
Nmap("<C-Space>", toggleTerminal, "Toggle terminal")
Nmap("<F2>", ":nohl<CR>", "Remove search highlight")
Nmap("<F3>", Global.leadMultiSpaceCalc, "Set leadmultispace according to shiftwidth")
Nmap("<F4>", ":Inspect<CR>", "Echo syntax group")
Nmap("<F5>", Global.apply_colorscheme, "Apply mini.base16 colorscheme")
Nmap("<F6>", ":TSContextToggle<CR>", "Toggle treesitter context")
Nmap("<F7>", MiniNotify.clear, "Clear all notifications")
Nmap("<Space><Space><Space>", toggleSpaces, "Expand tabs")
Nmap("<Tab><Tab><Tab>", toggleTabs, "Contract tabs")
Nmap("<leader>H", ':lua vim.fn.setloclist(MiniDiff.export("qf", { scope = "all" }))<CR>', "List diff hunks")
Nmap("<leader>bD", ":lua MiniBufremove.delete(0, true)<CR>", "Delete!")
Nmap("<leader>bW", ":lua MiniBufremove.wipeout(0, true)<CR>", "Wipeout!")
Nmap("<leader>ba", ":b#<CR>", "Alternate")
Nmap("<leader>bd", ":lua MiniBufremove.delete()<CR>", "Delete")
Nmap("<leader>bn", ":tabnew %<CR>", "Open current buffer in full screen")
Nmap("<leader>bw", ":lua MiniBufremove.wipeout()<CR>", "Wipeout")
Nmap("<leader>bz", MiniMisc.zoom, "Open current buffer in zoomed manner")
Nmap("<leader>cP", '"+P', "Paste to clipboard")
Nmap("<leader>cX", '"+X', "Cut to clipboard")
Nmap("<leader>cY", '"+Y', "Copy to clipboard")
Nmap("<leader>cp", '"+p', "Paste to clipboard")
Nmap("<leader>cx", '"+x', "Cut to clipboard")
Nmap("<leader>cy", '"+y', "Copy to clipboard")
Nmap("<leader>dB", ":lua require('dap').list_breakpoints()<CR>", "List breakpoints")
Nmap("<leader>dC", ":lua require('dap').clear_breakpoints()<CR>", "Clear breakpoints")
Nmap("<leader>dS", ":lua require('dap.ui.widgets').centered_float(require('dap.ui.widgets').scopes)<CR>", "Scopes")
Nmap("<leader>db", ":lua require('dap').toggle_breakpoint()<CR>", "Toggle breakpoint")
Nmap("<leader>dc", ":lua require('dap').continue()<CR>", "Continue")
Nmap("<leader>df", ":lua require('dap.ui.widgets').centered_float(require('dap.ui.widgets').frames)<CR>", "Frames")
Nmap("<leader>dh", ":lua require('dap.ui.widgets').hover()<CR>", "Hover value")
Nmap("<leader>dl", ":lua require('dap').run_last()<CR>", "Run Last")
Nmap("<leader>dlp", ":lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log: '))<CR>", "Set log point")
Nmap("<leader>dp", ":lua require('dap.ui.widgets').preview()<CR>", "Preview")
Nmap("<leader>dr", ":lua require('dap').repl.open({}, 'vsplit new')<CR>", "Open Repl")
Nmap("<leader>dsO", ":lua require('dap').step_over()<CR>", "Step over")
Nmap("<leader>dsi", ":lua require('dap').step_into()<CR>", "Step into")
Nmap("<leader>dso", ":lua require('dap').step_out()<CR>", "Step out")
Nmap("<leader>ef", ":lua if not MiniFiles.close() then MiniFiles.open(vim.api.nvim_buf_get_name(0)) end<CR>", "Buf")
Nmap("<leader>et", ":lua if not MiniFiles.close() then MiniFiles.open() end<CR>", "Toggle file explorer")
Nmap("<leader>fM", ':Pick marks scope="all"<CR>', "Search workspace marks")
Nmap("<leader>fS", ":Pick grep_live<CR>", "Search content live")
Nmap("<leader>fX", ':Pick diagnostic scope="all"<CR>', "Search workspace diagnostics")
Nmap("<leader>fY", ':Pick lsp scope="workspace_symbol"<CR>', "Search workspace symbols")
Nmap("<leader>fb", ":Pick buffers<CR>", "Search buffers")
Nmap("<leader>ff", ":Pick files<CR>", "Search files")
Nmap("<leader>fgC", ":Pick git_commits<CR>", "Search commits")
Nmap("<leader>fgb", ":Pick git_branches<CR>", "Search branches")
Nmap("<leader>fgc", ':Pick git_commits path="%"<CR>', "Search buffer commits")
Nmap("<leader>fgf", ":Pick git_files<CR>", "Search git files")
Nmap("<leader>fgs", ':Pick git_hunks scope="staged"<CR>', "Search git hunks staged")
Nmap("<leader>fgu", ':Pick git_hunks scope="unstaged"<CR>', "Search git hunks unstaged")
Nmap("<leader>fh", ":Pick hl_groups<CR>", "Search highlight groups")
Nmap("<leader>fk", ":Pick keymaps<CR>", "Search keymaps")
Nmap("<leader>fl", ':Pick buf_lines scope="current"<CR>', "Search buffer lines")
Nmap("<leader>fm", ':Pick marks scope="buf"<CR>', "Search document marks")
Nmap("<leader>fo", ':Pick list scope="location"<CR>', "Search loclist")
Nmap("<leader>fq", ':Pick list scope="quickfix"<CR>', "Search quickfix")
Nmap("<leader>fr", ":Pick resume<CR>", "Resume latest picker")
Nmap("<leader>fs", ":Pick grep<CR>", "Search content")
Nmap("<leader>ft", ":Pick treesitter<CR>", "Search treesitter tree")
Nmap("<leader>fx", ':Pick diagnostic scope="current"<CR>', "Search document diagnostics")
Nmap("<leader>fy", ':Pick lsp scope="document_symbol"<CR>', "Search document symbols")
Nmap("<leader>gc", ":lua require('neogen').generate({ type = 'class' })<CR>", "Generate class annotations")
Nmap("<leader>gf", ":lua require('neogen').generate({ type = 'file' })<CR>", "Generate file annotations")
Nmap("<leader>gf", ":lua require('neogen').generate({ type = 'func' })<CR>", "Generate function annotations")
Nmap("<leader>gg", ":lua require('neogen').generate()<CR>", "Generate annotations")
Nmap("<leader>gt", ":lua require('neogen').generate({ type = 'type' })<CR>", "Generate type annotations")
Nmap("<leader>h", ':lua vim.fn.setloclist(MiniDiff.export("qf", {scope="current"}))<CR>', "List buffer diff hunks")
Nmap("<leader>lF", ":lua vim.lsp.buf.format()<CR>", "Lsp Format")
Nmap("<leader>lc", ":lua vim.lsp.buf.code_action()<CR>", "Code action")
Nmap("<leader>ldh", ":lua vim.diagnostic.open_float()<CR>", "Hover diagnostics")
Nmap("<leader>ldn", ":lua vim.diagnostic.goto_next()<CR>", "Goto next diagnostic")
Nmap("<leader>ldp", ":lua vim.diagnostic.goto_prev()<CR>", "Goto prev diagnostic")
Nmap("<leader>ldt", diagnosticVirtualTextToggle, "Virtual text toggle")
Nmap("<leader>lf", require("conform").format, "Format code")
Nmap("<leader>lgD", ":lua vim.lsp.buf.declaration()<CR>", "Goto declaration")
Nmap("<leader>lgb", "<C-t>", "Previous tag")
Nmap("<leader>lgd", ":lua vim.lsp.buf.definition()<CR>", "Goto definition")
Nmap("<leader>lgi", ":lua vim.lsp.buf.implementation()<CR>", "Goto implementation")
Nmap("<leader>lgr", ":lua vim.lsp.buf.references()<CR>", "Goto references")
Nmap("<leader>lgs", ":lua vim.lsp.buf.signature_help()<CR>", "Signature help")
Nmap("<leader>lgtd", ":lua vim.lsp.buf.type_definition()<CR>", "Goto type definition")
Nmap("<leader>lh", ":lua vim.lsp.buf.hover()<CR>", "Hover symbol")
Nmap("<leader>li", ":lua vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())<CR>", "Inlay hints toggle")
Nmap("<leader>lr", ":lua vim.lsp.buf.rename()<CR>", "Rename")
Nmap("<leader>ql", ":lua require('quicker').toggle({ loclist = true })<CR>", "Toggle loclist")
Nmap("<leader>qq", require("quicker").toggle, "Toggle quickfix")
Nmap("<leader>vf", "<cmd>lua Global.miniPickVisits('', 'Core visits')<cr>", "Core visits")
Nmap("<leader>vr", "<cmd>lua MiniVisits.remove_label('core')<cr>", "Remove core label")
Nmap("<leader>vv", "<cmd>lua MiniVisits.add_label('core')<cr>", "Add core label")
Nmap("<leader>wo", ":only<CR>", "Close other windows")
Nmap("<leader>wq", ":close<CR>", "Close window")
Nmap("[e", ":lua MiniBracketed.diagnostic('backward',{severity=vim.diagnostic.severity.ERROR})<CR>", "Error last")
Nmap("]e", ":lua MiniBracketed.diagnostic('forward',{severity=vim.diagnostic.severity.ERROR})<CR>", "Error forward")
Nmap("gB", ":norm gxiagxila<CR>", "Move arg left")
Nmap("gL", ":lua MiniGit.show_at_cursor()<CR>", "Git line history")
Nmap("gb", ":norm gxiagxina<CR>", "Move arg right")
Nmap("gz", ":lua MiniDiff.toggle_overlay()<CR>", "Show diff")
Tmap("<Space><Esc>", "<C-\\><C-n>", "Escape terminal mode")
Vmap("<leader>cP", '"+P', "Paste to clipboard")
Vmap("<leader>cX", '"+X', "Cut to clipboard")
Vmap("<leader>cY", '"+Y', "Copy to clipboard")
Vmap("<leader>cp", '"+p', "Paste to clipboard")
Vmap("<leader>cx", '"+x', "Cut to clipboard")
Vmap("<leader>cy", '"+y', "Copy to clipboard")
Xmap("<leader>lf", require("conform").format, "Format code")
end)
-- Autocommands registration
now(function()
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate,MiniGitUpdated",
callback = function(args)
if args.match == "MiniGitUpdated" then
-- Remove additional git information
local summary = vim.b[args.buf].minigit_summary
vim.b[args.buf].minigit_summary_string = summary.head_name or ""
elseif args.match == "MiniFilesBufferCreate" then
-- Create mapping for setting current dir as pwd for neovim
local b = args.data.buf_id
vim.keymap.set("n", "g~", function()
local path = (MiniFiles.get_fs_entry() or {}).path
if path == nil then
return vim.notify("Cursor is not on valid entry")
end
vim.fn.chdir(vim.fs.dirname(path))
end, { buffer = b, desc = "Set cwd" })
-- Create mapping for yanking path of entry
vim.keymap.set("n", "gy", function()
local path = (MiniFiles.get_fs_entry() or {}).path
if path == nil then
return vim.notify("Cursor is not on valid entry")
end
vim.fn.setreg("", path)
end, { buffer = b, desc = "Yank path" })
-- Create mapping for yanking path of entry to clipboard
vim.keymap.set("n", "gY", function()
local path = (MiniFiles.get_fs_entry() or {}).path
if path == nil then
return vim.notify("Cursor is not on valid entry")
end
vim.fn.setreg("+", path)
end, { buffer = b, desc = "Yank path" })
-- Toggle dotfiles
local show_dotfiles = true
local filter_show = function(fs_entry)
return true
end
local filter_hide = function(fs_entry)
return not vim.startswith(fs_entry.name, ".")
end
local toggle_dotfiles = function()
show_dotfiles = not show_dotfiles
local new_filter = show_dotfiles and filter_show or filter_hide
MiniFiles.refresh({ content = { filter = new_filter } })