-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
2-ui.lua
707 lines (673 loc) · 26.3 KB
/
2-ui.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
-- User interface
-- Things that make the GUI better.
-- Sections:
-- -> tokyonight [theme]
-- -> astrotheme [theme]
-- -> alpha-nvim [greeter]
-- -> nvim-notify [notifications]
-- -> mini.indentscope [guides]
-- -> heirline-components.nvim [ui components]
-- -> heirline [ui components]
-- -> telescope [search]
-- -> telescope-fzf-native.nvim [search backend]
-- -> smart-splits [window-dimming]
-- -> dressing.nvim [better ui elements]
-- -> noice.nvim [better cmd/search line]
-- -> nvim-web-devicons [icons | ui]
-- -> lspkind.nvim [icons | lsp]
-- -> nvim-scrollbar [scrollbar]
-- -> mini.animate [animations]
-- -> highlight-undo [highlights]
-- -> which-key [on-screen keybinding]
local utils = require "base.utils"
local is_windows = vim.fn.has('win32') == 1 -- true if on windows
local is_android = vim.fn.isdirectory('/data') == 1 -- true if on android
return {
-- tokyonight [theme]
-- https://github.com/folke/tokyonight.nvim
{
"Zeioth/tokyonight.nvim",
event = "User LoadColorSchemes",
opts = {
dim_inactive = false,
styles = {
comments = { italic = true },
keywords = { italic = true },
},
}
},
-- astrotheme [theme]
-- https://github.com/AstroNvim/astrotheme
{
"AstroNvim/astrotheme",
event = "User LoadColorSchemes",
opts = {
palette = "astrodark",
plugins = { ["dashboard-nvim"] = true },
},
},
-- alpha-nvim [greeter]
-- https://github.com/goolord/alpha-nvim
{
"goolord/alpha-nvim",
cmd = "Alpha",
-- setup header and buttonts
opts = function()
local dashboard = require("alpha.themes.dashboard")
-- Header
-- dashboard.section.header.val = {
-- " ",
-- " ████ ██████ █████ ██ ",
-- " ███████████ █████ ",
-- " █████████ ███████████████████ ███ ███████████ ",
-- " █████████ ███ █████████████ █████ ██████████████ ",
-- " █████████ ██████████ █████████ █████ █████ ████ █████ ",
-- " ███████████ ███ ███ █████████ █████ █████ ████ █████ ",
-- " ██████ █████████████████████ ████ █████ █████ ████ ██████ ",
-- }
-- dashboard.section.header.val = {
-- ' ▟▙ ',
-- ' ▝▘ ',
-- '██▃▅▇█▆▖ ▗▟████▙▖ ▄████▄ ██▄ ▄██ ██ ▗▟█▆▄▄▆█▙▖',
-- '██▛▔ ▝██ ██▄▄▄▄██ ██▛▔▔▜██ ▝██ ██▘ ██ ██▛▜██▛▜██',
-- '██ ██ ██▀▀▀▀▀▘ ██▖ ▗██ ▜█▙▟█▛ ██ ██ ██ ██',
-- '██ ██ ▜█▙▄▄▄▟▊ ▀██▙▟██▀ ▝████▘ ██ ██ ██ ██',
-- '▀▀ ▀▀ ▝▀▀▀▀▀ ▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀',
-- }
-- dashboard.section.header.val = {
-- ' ▟▙ ',
-- ' ▝▘ ',
-- '██▃▅▇█▆▖ ██▄ ▄██ ██ ▗▟█▆▄▄▆█▙▖',
-- '██▛▔ ▝██ ▝██ ██▘ ██ ██▛▜██▛▜██',
-- '██ ██ ▜█▙▟█▛ ██ ██ ██ ██',
-- '██ ██ ▝████▘ ██ ██ ██ ██',
-- '▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀ ▀▀',
-- }
-- Generated with https://www.fancytextpro.com/BigTextGenerator/Larry3D
-- dashboard.section.header.val = {
-- [[ __ __ __ __ ]],
-- [[/\ \/\ \ /\ \/\ \ __ ]],
-- [[\ \ `\\ \ __ ___ \ \ \ \ \/\_\ ___ ___ ]],
-- [[ \ \ , ` \ /'__`\ / __`\\ \ \ \ \/\ \ /' __` __`\ ]],
-- [[ \ \ \`\ \/\ __//\ \L\ \\ \ \_/ \ \ \/\ \/\ \/\ \ ]],
-- [[ \ \_\ \_\ \____\ \____/ \ `\___/\ \_\ \_\ \_\ \_\]],
-- [[ \/_/\/_/\/____/\/___/ `\/__/ \/_/\/_/\/_/\/_/]],
-- }
-- dashboard.section.header.val = {
-- ' ',
-- ' ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ',
-- ' ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ',
-- ' ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ',
-- ' ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ',
-- ' ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ',
-- ' ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ',
-- ' ',
-- }
-- dashboard.section.header.val = {
-- [[ __ ]],
-- [[ ___ __ __ /\_\ ___ ___ ]],
-- [[/' _ `\/\ \/\ \\/\ \ /' __` __`\ ]],
-- [[/\ \/\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
-- [[\ \_\ \_\ \___/ \ \_\ \_\ \_\ \_\]],
-- [[ \/_/\/_/\/__/ \/_/\/_/\/_/\/_/]],
-- }
if is_android then
dashboard.section.header.val = {
[[ __ ]],
[[ __ __ /\_\ ___ ___ ]],
[[/\ \/\ \\/\ \ /' __` __`\ ]],
[[\ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
[[ \ \___/ \ \_\ \_\ \_\ \_\]],
[[ \/__/ \/_/\/_/\/_/\/_/]],
}
else
dashboard.section.header.val = {
[[888b 88 88]],
[[8888b 88 88]],
[[88 `8b 88 88]],
[[88 `8b 88 ,adPPYba, 8b,dPPYba, 88,dPYba,,adPYba, ,adPPYYba, 88]],
[[88 `8b 88 a8" "8a 88P' "Y8 88P' "88" "8a "" `Y8 88]],
[[88 `8b 88 8b d8 88 88 88 88 ,adPPPPP88 88]],
[[88 `8888 "8a, ,a8" 88 88 88 88 88, ,88 88]],
[[88 `888 `"YbbdP"' 88 88 88 88 `"8bbdP"Y8 88]],
[[ __ ]],
[[ ___ __ __ /\_\ ___ ___ ]],
[[ /' _ `\/\ \/\ \\/\ \ /' __` __`\ ]],
[[ /\ \/\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
[[ \ \_\ \_\ \___/ \ \_\ \_\ \_\ \_\]],
[[ \/_/\/_/\/__/ \/_/\/_/\/_/\/_/]],
}
end
dashboard.section.header.opts.hl = "DashboardHeader"
vim.cmd "highlight DashboardHeader guifg=#F7778F"
-- If on windows, don't show the 'ranger' button
local ranger_button = dashboard.button("r", "🐍 Ranger ", "<cmd>RnvimrToggle<CR>")
if is_windows then ranger_button = nil end
-- Buttons
dashboard.section.buttons.val = {
dashboard.button("n", "📄 New ", "<cmd>ene<CR>"),
dashboard.button("e", "🌺 Recent ", "<cmd>Telescope oldfiles<CR>"),
ranger_button,
dashboard.button(
"s",
"🔎 Sessions",
"<cmd>SessionManager! load_session<CR>"
),
dashboard.button("p", "💼 Projects", "<cmd>Telescope projects<CR>"),
dashboard.button("", ""),
dashboard.button("q", " Quit", "<cmd>exit<CR>"),
-- --button("LDR f '", " Bookmarks "),
}
---- Vertical margins
dashboard.config.layout[1].val =
vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0) * 0.10) } -- Above header
dashboard.config.layout[3].val =
vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0) * 0.10) } -- Above buttons
-- Disable autocmd and return
dashboard.config.opts.noautocmd = true
return dashboard
end,
config = function(_, opts)
-- Footer
require("alpha").setup(opts.config)
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
desc = "Add Alpha dashboard footer",
once = true,
callback = function()
local stats = require("lazy").stats()
stats.real_cputime = not is_windows
local ms = math.floor(stats.startuptime * 100 + 0.5) / 100
opts.section.footer.val = {
" ",
" ",
" ",
"Loaded " .. stats.loaded .. " plugins in " .. ms .. "ms",
".............................",
}
opts.section.footer.opts.hl = "DashboardFooter"
vim.cmd "highlight DashboardFooter guifg=#D29B68"
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
},
-- [notifications]
-- https://github.com/rcarriga/nvim-notify
{
"rcarriga/nvim-notify",
event = "User BaseDefered",
opts = function()
local fps
if is_android then fps = 30 else fps = 144 end
return {
timeout = 2500,
fps = fps,
max_height = function() return math.floor(vim.o.lines * 0.75) end,
max_width = function() return math.floor(vim.o.columns * 0.75) end,
on_open = function(win)
-- enable markdown support on notifications
vim.api.nvim_win_set_config(win, { zindex = 175 })
if not vim.g.notifications_enabled then
vim.api.nvim_win_close(win, true)
end
if not package.loaded["nvim-treesitter"] then
pcall(require, "nvim-treesitter")
end
vim.wo[win].conceallevel = 3
local buf = vim.api.nvim_win_get_buf(win)
if not pcall(vim.treesitter.start, buf, "markdown") then
vim.bo[buf].syntax = "markdown"
end
vim.wo[win].spell = false
end,
}
end,
config = function(_, opts)
local notify = require("notify")
notify.setup(opts)
vim.notify = notify
end,
},
-- mini.indentscope [guides]
-- https://github.com/echasnovski/mini.indentscope
{
"echasnovski/mini.indentscope",
event = { "BufReadPre", "BufNewFile" },
opts = {
draw = { delay = 0, animation = function() return 0 end },
options = { border = "top", try_as_border = true },
symbol = "▏",
},
config = function(_, opts)
require("mini.indentscope").setup(opts)
-- Disable for certain filetypes
vim.api.nvim_create_autocmd({ "FileType" }, {
desc = "Disable indentscope for certain filetypes",
callback = function()
local ignored_filetypes = {
"aerial",
"dashboard",
"help",
"lazy",
"leetcode.nvim",
"mason",
"neo-tree",
"NvimTree",
"neogitstatus",
"notify",
"startify",
"toggleterm",
"Trouble"
}
if vim.tbl_contains(ignored_filetypes, vim.bo.filetype) then
vim.b.miniindentscope_disable = true
end
end,
})
end
},
-- heirline-components.nvim [ui components]
-- https://github.com/Zeioth/heirline-components.nvim
-- Collection of components to use on your heirline config.
{
"zeioth/heirline-components.nvim",
opts = {
icons = require("base.icons.nerd_font")
}
},
-- heirline [ui components]
-- https://github.com/rebelot/heirline.nvim
-- Use it to customize the components of your user interface,
-- Including tabline, winbar, statuscolumn, statusline.
-- Be aware some components are positional. Read heirline documentation.
{
"rebelot/heirline.nvim",
dependencies = { "zeioth/heirline-components.nvim" },
event = "User BaseDefered",
opts = function()
local lib = require "heirline-components.all"
return {
opts = {
disable_winbar_cb = function(args) -- We do this to avoid showing it on the greeter.
local is_disabled = not require("heirline-components.buffer").is_valid(args.buf) or
lib.condition.buffer_matches({
buftype = { "terminal", "prompt", "nofile", "help", "quickfix" },
filetype = { "NvimTree", "neo%-tree", "dashboard", "Outline", "aerial" },
}, args.buf)
return is_disabled
end,
},
tabline = { -- UI upper bar
lib.component.tabline_conditional_padding(),
lib.component.tabline_buffers(),
lib.component.fill { hl = { bg = "tabline_bg" } },
lib.component.tabline_tabpages()
},
winbar = { -- UI breadcrumbs bar
init = function(self) self.bufnr = vim.api.nvim_get_current_buf() end,
fallthrough = false,
-- Winbar for terminal, neotree, and aerial.
{
condition = function() return not lib.condition.is_active() end,
{
lib.component.neotree(),
lib.component.compiler_play(),
lib.component.fill(),
lib.component.compiler_build_type(),
lib.component.compiler_redo(),
lib.component.aerial(),
},
},
-- Regular winbar
{
lib.component.neotree(),
lib.component.compiler_play(),
lib.component.fill(),
lib.component.breadcrumbs(),
lib.component.fill(),
lib.component.compiler_redo(),
lib.component.aerial(),
}
},
statuscolumn = { -- UI left column
init = function(self) self.bufnr = vim.api.nvim_get_current_buf() end,
lib.component.foldcolumn(),
lib.component.numbercolumn(),
lib.component.signcolumn(),
} or nil,
statusline = { -- UI statusbar
hl = { fg = "fg", bg = "bg" },
lib.component.mode(),
lib.component.git_branch(),
lib.component.file_info(),
lib.component.git_diff(),
lib.component.diagnostics(),
lib.component.fill(),
lib.component.cmd_info(),
lib.component.fill(),
lib.component.lsp(),
lib.component.compiler_state(),
lib.component.virtual_env(),
lib.component.nav(),
lib.component.mode { surround = { separator = "right" } },
},
}
end,
config = function(_, opts)
local heirline = require("heirline")
local heirline_components = require "heirline-components.all"
-- Setup
heirline_components.init.subscribe_to_events()
heirline.load_colors(heirline_components.hl.get_colors())
heirline.setup(opts)
end,
},
-- Telescope [search] + [search backend] dependency
-- https://github.com/nvim-telescope/telescope.nvim
-- https://github.com/nvim-telescope/telescope-fzf-native.nvim
-- https://github.com/debugloop/telescope-undo.nvim
-- NOTE: Normally, plugins that depend on Telescope are defined separately.
-- But its Telescope extension is added in the Telescope 'config' section.
{
"nvim-telescope/telescope.nvim",
dependencies = {
{
"debugloop/telescope-undo.nvim",
cmd = "Telescope",
},
{
"nvim-telescope/telescope-fzf-native.nvim",
enabled = vim.fn.executable "make" == 1,
build = "make",
},
},
cmd = "Telescope",
opts = function()
local get_icon = require("base.utils").get_icon
local actions = require("telescope.actions")
local mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<ESC>"] = actions.close,
["<C-c>"] = false,
},
n = { ["q"] = actions.close },
}
return {
defaults = {
prompt_prefix = get_icon("Selected", 1),
selection_caret = get_icon("Selected", 1),
path_display = { "truncate" },
sorting_strategy = "ascending",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.50,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
mappings = mappings,
},
extensions = {
undo = {
use_delta = true,
side_by_side = true,
diff_context_lines = 0,
entry_format = " #$ID, $STAT, $TIME",
layout_strategy = "horizontal",
layout_config = {
preview_width = 0.65,
},
mappings = {
i = {
["<cr>"] = require("telescope-undo.actions").yank_additions,
["<S-cr>"] = require("telescope-undo.actions").yank_deletions,
["<C-cr>"] = require("telescope-undo.actions").restore,
},
},
},
},
}
end,
config = function(_, opts)
local telescope = require("telescope")
telescope.setup(opts)
-- Here we define the Telescope extension for all plugins.
-- If you delete a plugin, you can also delete its Telescope extension.
if utils.is_available("nvim-notify") then telescope.load_extension("notify") end
if utils.is_available("telescope-fzf-native.nvim") then telescope.load_extension("fzf") end
if utils.is_available("telescope-undo.nvim") then telescope.load_extension("undo") end
if utils.is_available("project.nvim") then telescope.load_extension("projects") end
if utils.is_available("LuaSnip") then telescope.load_extension("luasnip") end
if utils.is_available("aerial.nvim") then telescope.load_extension("aerial") end
if utils.is_available("nvim-neoclip.lua") then
telescope.load_extension("neoclip")
telescope.load_extension("macroscope")
end
end,
},
-- [better ui elements]
-- https://github.com/stevearc/dressing.nvim
{
"stevearc/dressing.nvim",
event = "User BaseDefered",
opts = {
input = { default_prompt = "➤ " },
select = { backend = { "telescope", "builtin" } },
}
},
-- Noice.nvim [better cmd/search line]
-- https://github.com/folke/noice.nvim
-- We use it for:
-- * cmdline: Display treesitter for :
-- * search: Display a magnifier instead of /
--
-- We don't use it for:
-- * LSP status: We use a heirline component for this.
-- * Search results: We use a heirline component for this.
{
"folke/noice.nvim",
event = "User BaseDefered",
opts = function()
local enable_conceal = false -- Hide command text if true
return {
presets = { bottom_search = true }, -- The kind of popup used for /
cmdline = {
view = "cmdline", -- The kind of popup used for :
format = {
cmdline = { conceal = enable_conceal },
search_down = { conceal = enable_conceal },
search_up = { conceal = enable_conceal },
filter = { conceal = enable_conceal },
lua = { conceal = enable_conceal },
help = { conceal = enable_conceal },
input = { conceal = enable_conceal },
}
},
-- Disable every other noice feature
messages = { enabled = false },
lsp = {
hover = { enabled = false },
signature = { enabled = false },
progress = { enabled = false },
message = { enabled = false },
smart_move = { enabled = false },
},
}
end
},
-- UI icons [icons]
-- https://github.com/nvim-tree/nvim-web-devicons
{
"nvim-tree/nvim-web-devicons",
enabled = vim.g.icons_enabled,
event = "User BaseDefered",
opts = {
override = {
default_icon = {
icon = require("base.utils").get_icon("DefaultFile"),
name = "default"
},
deb = { icon = "", name = "Deb" },
lock = { icon = "", name = "Lock" },
mp3 = { icon = "", name = "Mp3" },
mp4 = { icon = "", name = "Mp4" },
out = { icon = "", name = "Out" },
["robots.txt"] = { icon = "", name = "Robots" },
ttf = { icon = "", name = "TrueTypeFont" },
rpm = { icon = "", name = "Rpm" },
woff = { icon = "", name = "WebOpenFontFormat" },
woff2 = { icon = "", name = "WebOpenFontFormat2" },
xz = { icon = "", name = "Xz" },
zip = { icon = "", name = "Zip" },
},
},
config = function(_, opts)
require("nvim-web-devicons").setup(opts)
pcall(vim.api.nvim_del_user_command, "NvimWebDeviconsHiTest")
end
},
-- LSP icons [icons]
-- https://github.com/onsails/lspkind.nvim
{
"onsails/lspkind.nvim",
opts = {
mode = "symbol",
symbol_map = {
Array = "",
Boolean = "⊨",
Class = "",
Constructor = "",
Key = "",
Namespace = "",
Null = "NULL",
Number = "#",
Object = "",
Package = "",
Property = "",
Reference = "",
Snippet = "",
String = "",
TypeParameter = "",
Unit = "",
},
menu = {},
},
enabled = vim.g.icons_enabled,
config = function(_, opts)
require("lspkind").init(opts)
end,
},
-- nvim-scrollbar [scrollbar]
-- https://github.com/petertriho/nvim-scrollbar
{
"petertriho/nvim-scrollbar",
event = "User BaseFile",
opts = {
handlers = {
gitsigns = true, -- gitsigns integration (display hunks)
ale = true, -- lsp integration (display errors/warnings)
search = false, -- hlslens integration (display search result)
},
excluded_filetypes = {
"cmp_docs",
"cmp_menu",
"noice",
"prompt",
"TelescopePrompt",
"alpha",
},
},
},
-- mini.animate [animations]
-- https://github.com/echasnovski/mini.animate
-- HINT: if one of your personal keymappings fail due to mini.animate, try to
-- disable it during the keybinding using vim.g.minianimate_disable = true
{
"echasnovski/mini.animate",
event = "User BaseFile",
enabled = not is_android,
opts = function()
-- don't use animate when scrolling with the mouse
local mouse_scrolled = false
for _, scroll in ipairs { "Up", "Down" } do
local key = "<ScrollWheel" .. scroll .. ">"
vim.keymap.set({ "", "i" }, key, function()
mouse_scrolled = true
return key
end, { expr = true })
end
local animate = require("mini.animate")
return {
open = { enable = false }, -- true causes issues on nvim-spectre
resize = {
timing = animate.gen_timing.linear { duration = 33, unit = "total" },
},
scroll = {
timing = animate.gen_timing.linear { duration = 50, unit = "total" },
subscroll = animate.gen_subscroll.equal {
predicate = function(total_scroll)
if mouse_scrolled then
mouse_scrolled = false
return false
end
return total_scroll > 1
end,
},
},
cursor = {
enable = false, -- We don't want cursor ghosting
timing = animate.gen_timing.linear { duration = 26, unit = "total" },
},
}
end,
},
-- highlight-undo
-- https://github.com/tzachar/highlight-undo.nvim
-- This plugin only flases on redo.
-- But we also have a autocmd to flash on yank.
{
"tzachar/highlight-undo.nvim",
event = "User BaseDefered",
opts = {
hlgroup = "CurSearch",
duration = 150,
keymaps = {
{ "n", "u", "undo", {} }, -- If you remap undo/redo, change this
{ "n", "<C-r>", "redo", {} },
},
},
config = function(_, opts)
require("highlight-undo").setup(opts)
-- Also flash on yank.
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight yanked text",
pattern = "*",
callback = function() vim.highlight.on_yank() end,
})
end,
},
-- which-key.nvim [on-screen keybindings]
-- https://github.com/folke/which-key.nvim
{
"folke/which-key.nvim",
event = "User BaseDefered",
opts = {
icons = { group = vim.g.icons_enabled and "" or "+", separator = "" },
disable = { filetypes = { "TelescopePrompt" } },
},
config = function(_, opts)
require("which-key").setup(opts)
require("base.utils").which_key_register()
end,
},
} -- end of return