dotfiles/modules/programs/nvim/plugins/mini-nvim.lua

111 lines
3.8 KiB
Lua
Raw Normal View History

2023-05-28 18:23:25 +02:00
require("mini.align").setup()
require("mini.move").setup()
require("mini.pairs").setup()
require("mini.starter").setup()
require("mini.surround").setup({
-- Add custom surroundings to be used on top of builtin ones. For more
-- information with examples, see `:h MiniSurround.config`.
custom_surroundings = nil,
-- Duration (in ms) of highlight when calling `MiniSurround.highlight()`
highlight_duration = 500,
-- Module mappings. Use `''` (empty string) to disable one.
mappings = {
add = "gSa", -- Add surrounding in Normal and Visual modes
delete = "gSd", -- Delete surrounding
find = "gSf", -- Find surrounding (to the right)
find_left = "gSF", -- Find surrounding (to the left)
highlight = "gSh", -- Highlight surrounding
replace = "gSr", -- Replace surrounding
update_n_lines = "gSn", -- Update `n_lines`
suffix_last = "l", -- Suffix to search with "prev" method
suffix_next = "n", -- Suffix to search with "next" method
},
-- Number of lines within which surrounding is searched
n_lines = 20,
-- Whether to respect selection type:
-- - Place surroundings on separate lines in linewise mode.
-- - Place surroundings on each line in blockwise mode.
respect_selection_type = false,
-- How to search for surrounding (first inside current line, then inside
-- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev',
-- 'cover_or_nearest', 'next', 'prev', 'nearest'. For more details,
-- see `:h MiniSurround.config`.
search_method = "cover",
-- Whether to disable showing non-error feedback
silent = false,
})
2023-05-28 18:23:25 +02:00
require("mini.tabline").setup()
local tabline_current = vim.api.nvim_get_hl(0, { name = "MiniTablineCurrent" })
vim.api.nvim_set_hl(0, "MiniTablineCurrent", {
fg = tabline_current.fg,
bg = tabline_current.bg,
bold = true,
italic = true,
})
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 = 140 })
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
local location = MiniStatusline.section_location({ trunc_width = 75 })
local mode_hl_inverse = mode_hl .. "Inverse"
-- Usage of `MiniStatusline.combine_groups()` ensures highlighting and
-- correct padding with spaces between groups (accounts for 'missing'
-- sections, etc.)
return MiniStatusline.combine_groups({
{ hl = mode_hl_inverse, strings = {} },
"",
{ hl = mode_hl, strings = { mode } },
{ hl = "MiniStatuslineDevinfo", strings = { git, diagnostics } },
"%<", -- Mark general truncate point
{ hl = "MiniStatuslineFilename", strings = { filename } },
"%=", -- End left alignment
{ hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
{ hl = mode_hl, strings = { location } },
{ hl = mode_hl_inverse, strings = {} },
"",
})
end,
},
})
local MiniStatuslineModes = {
"MiniStatuslineModeInsert",
"MiniStatuslineModeNormal",
"MiniStatuslineModeReplace",
"MiniStatuslineModeVisual",
"MiniStatuslineModeCommand",
"MiniStatuslineModeOther",
}
for _, mode_hl in ipairs(MiniStatuslineModes) do
local hl_table = vim.api.nvim_get_hl(0, { name = mode_hl })
local fg = hl_table.fg
hl_table.fg = hl_table.bg
hl_table.bg = fg
vim.api.nvim_set_hl(0, mode_hl .. "Inverse", hl_table)
end
local animate = require("mini.animate")
local animation = {
timing = animate.gen_timing.quadratic({ duration = 100, unit = "total" }),
}
animate.setup({
cursor = animation,
scroll = { enable = false },
resize = animation,
open = animation,
close = animation,
})