You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kickstart.nvim/lua/custom/plugins/mini.lua

199 lines
7.1 KiB
Lua

return {
{
'echasnovski/mini.cursorword',
version = false,
lazy = true,
event = 'CursorMoved',
config = function()
require('mini.cursorword').setup()
end,
},
{
'echasnovski/mini.indentscope',
version = false,
event = 'BufEnter',
opts = {
symbol = '',
options = { try_as_border = true },
draw = {
animation = function()
return 0
end,
},
},
init = function()
-- local macchiato = require('catppuccin.palettes').get_palette 'macchiato'
-- vim.api.nvim_create_autocmd('FileType', {
-- pattern = {
-- 'help',
-- 'lazy',
-- 'mason',
-- 'notify',
-- 'oil',
-- 'Oil',
-- },
-- callback = function()
-- vim.b.miniindentscope_disable = true
-- end,
-- })
-- vim.api.nvim_set_hl(0, 'MiniIndentscopeSymbol', { fg = macchiato.mauve })
end,
},
{
"echasnovski/mini.files",
opts = {
windows = {
preview = true,
width_focus = 30,
width_preview = 30,
},
options = {
-- Whether to use for editing directories
-- Disabled by default in LazyVim because neo-tree is used for that
use_as_default_explorer = false,
},
},
keys = {
{
"<leader>fm",
function()
require("mini.files").open(vim.api.nvim_buf_get_name(0), true)
end,
desc = "Open mini.files (Directory of Current File)",
},
{
"<leader>fM",
function()
require("mini.files").open(vim.uv.cwd(), true)
end,
desc = "Open mini.files (cwd)",
},
},
config = function(_, opts)
require("mini.files").setup(opts)
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
require("mini.files").refresh({ content = { filter = new_filter } })
end
local map_split = function(buf_id, lhs, direction, close_on_file)
local rhs = function()
local new_target_window
local cur_target_window = require("mini.files").get_explorer_state().target_window
if cur_target_window ~= nil then
vim.api.nvim_win_call(cur_target_window, function()
vim.cmd("belowright " .. direction .. " split")
new_target_window = vim.api.nvim_get_current_win()
end)
require("mini.files").set_target_window(new_target_window)
require("mini.files").go_in({ close_on_file = close_on_file })
end
end
local desc = "Open in " .. direction .. " split"
if close_on_file then
desc = desc .. " and close"
end
vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc })
end
local files_set_cwd = function()
local cur_entry_path = MiniFiles.get_fs_entry().path
local cur_directory = vim.fs.dirname(cur_entry_path)
if cur_directory ~= nil then
vim.fn.chdir(cur_directory)
end
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
vim.keymap.set(
"n",
opts.mappings and opts.mappings.toggle_hidden or "g.",
toggle_dotfiles,
{ buffer = buf_id, desc = "Toggle hidden files" }
)
vim.keymap.set(
"n",
opts.mappings and opts.mappings.change_cwd or "gc",
files_set_cwd,
{ buffer = args.data.buf_id, desc = "Set cwd" }
)
map_split(buf_id, opts.mappings and opts.mappings.go_in_horizontal or "<C-w>s", "horizontal", false)
map_split(buf_id, opts.mappings and opts.mappings.go_in_vertical or "<C-w>v", "vertical", false)
map_split(buf_id, opts.mappings and opts.mappings.go_in_horizontal_plus or "<C-w>S", "horizontal", true)
map_split(buf_id, opts.mappings and opts.mappings.go_in_vertical_plus or "<C-w>V", "vertical", true)
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
Snacks.rename.on_rename_file(event.data.from, event.data.to)
end,
})
end,
},
{
"echasnovski/mini.starter",
enabled = true,
config = function ()
require('mini.starter').setup({
-- Define the header
header = table.concat({
"================= =============== =============== ======== ========",
"\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //",
"||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||",
"|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||",
"||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||",
"|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||",
"||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||",
"|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||",
"||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||",
"|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||",
"|| `' || || `' || || `' || || | \\ / | ||",
"|| .===' `===. .==='.`===. .===' /==. | \\/ | ||",
"|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||",
"|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||",
"|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||",
"||.==' _-' `' | /==.||",
"==' _-' N E O V I M \\/ `==",
"\\ _-' `-_ /",
" `'' ``'",
}, "\n"),
-- Define the items to display in the starter
items = {
{ name = 'New File', action = 'enew', section = 'Actions' },
{ name = 'Open File', action = 'Telescope find_files', section = 'Actions' },
{ name = 'Recent Files', action = 'Telescope oldfiles', section = 'Actions' },
{ name = 'Config', action = 'edit ~/.config/nvim/init.lua', section = 'Config' },
{ name = 'Quit', action = 'qall', section = 'Actions' },
},
-- Define the footer
footer = os.date("%Y-%m-%d %H:%M:%S"),
})
end
},
}