nvim: Lazy load most mini.nvim modules
Except for mini.starter which we need right at the - well - start, we can lazy load most other modules. It's a little awkward since we lazy load them *within* the setup function with a manual autocommand but it should work fine for the time being.
This commit is contained in:
parent
b2e0621d12
commit
86dfc5ecbc
1 changed files with 65 additions and 59 deletions
|
@ -92,8 +92,8 @@ return {
|
|||
-- collection of plugins
|
||||
{
|
||||
"echasnovski/mini.nvim",
|
||||
version = "*",
|
||||
dependencies = { "rktjmp/fwatch.nvim" },
|
||||
dependencies = { "rktjmp/fwatch.nvim" }, -- for colorscheme updating
|
||||
event = "VimEnter", -- need to load pretty soon for Starter screen
|
||||
config = function()
|
||||
-- automatic callback to invoke 'mini.base16' when colorscheme file is changed
|
||||
local colorsfile = vim.fn.stdpath("state") .. "/colorscheme.lua"
|
||||
|
@ -112,62 +112,7 @@ return {
|
|||
end),
|
||||
})
|
||||
|
||||
require("mini.ai").setup()
|
||||
-- Align tables and other alignable things
|
||||
require("mini.align").setup({})
|
||||
|
||||
require("mini.bracketed").setup({
|
||||
{
|
||||
buffer = { suffix = "b", options = {} },
|
||||
comment = { suffix = "k", options = {} },
|
||||
conflict = { suffix = "" }, -- disable to use git-conflict instead
|
||||
diagnostic = { suffix = "d", options = {} },
|
||||
file = { suffix = "", options = {} },
|
||||
indent = { suffix = "" }, -- disable since we use indentscope above
|
||||
jump = { suffix = "j", options = {} },
|
||||
location = { suffix = "l", options = {} },
|
||||
oldfile = { suffix = "o", options = {} },
|
||||
quickfix = { suffix = "q", options = {} },
|
||||
treesitter = { suffix = "t", options = {} },
|
||||
undo = { suffix = "" }, -- disable since I don't need it
|
||||
window = { suffix = "w", options = {} },
|
||||
yank = { suffix = "y", options = {} },
|
||||
},
|
||||
})
|
||||
require("mini.comment").setup({
|
||||
hooks = {
|
||||
pre = function()
|
||||
-- use treesitter commentstring functionality if it's installed
|
||||
if require("core.util").is_available("ts_context_commentstring") then
|
||||
require("ts_context_commentstring.internal").update_commentstring()
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
require("mini.cursorword").setup({ delay = 500 })
|
||||
vim.api.nvim_set_hl(0, "MiniCursorword", { bold = true, underline = false })
|
||||
vim.api.nvim_set_hl(0, "MiniCursorwordCurrent", { bold = true, underline = false })
|
||||
|
||||
require("mini.files").setup()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "MiniFilesWindowUpdate",
|
||||
callback = function(args)
|
||||
vim.wo[args.data.win_id].number = true
|
||||
end,
|
||||
})
|
||||
|
||||
require("mini.fuzzy").setup()
|
||||
require("mini.indentscope").setup({
|
||||
symbol = "│",
|
||||
draw = { animation = require("mini.indentscope").gen_animation.none() },
|
||||
options = { indent_at_cursor = false },
|
||||
})
|
||||
require("mini.map").setup()
|
||||
require("mini.move").setup()
|
||||
require("mini.operators").setup()
|
||||
require("mini.pairs").setup()
|
||||
require("mini.trailspace").setup()
|
||||
-- this should be loaded as soon as the plugin is loaded
|
||||
local starter = require("mini.starter")
|
||||
starter.setup({
|
||||
evaluate_single = true,
|
||||
|
@ -190,8 +135,69 @@ return {
|
|||
starter.gen_hook.aligning("center", "center"),
|
||||
},
|
||||
})
|
||||
-- manually create lazy loading scenarios
|
||||
vim.api.nvim_create_autocmd({ "InsertEnter", "CursorHold" }, {
|
||||
once = true,
|
||||
callback = function()
|
||||
require("mini.ai").setup()
|
||||
-- Align tables and other alignable things
|
||||
require("mini.align").setup({})
|
||||
|
||||
require("mini.bracketed").setup({
|
||||
{
|
||||
buffer = { suffix = "b", options = {} },
|
||||
comment = { suffix = "k", options = {} },
|
||||
conflict = { suffix = "" }, -- disable to use git-conflict instead
|
||||
diagnostic = { suffix = "d", options = {} },
|
||||
file = { suffix = "", options = {} },
|
||||
indent = { suffix = "" }, -- disable since we use indentscope above
|
||||
jump = { suffix = "j", options = {} },
|
||||
location = { suffix = "l", options = {} },
|
||||
oldfile = { suffix = "o", options = {} }, -- FIXME: overwritten by wrapping defaults currently
|
||||
quickfix = { suffix = "q", options = {} },
|
||||
treesitter = { suffix = "t", options = {} },
|
||||
undo = { suffix = "" }, -- disable since I don't need it
|
||||
window = { suffix = "w", options = {} },
|
||||
yank = { suffix = "y", options = {} },
|
||||
},
|
||||
})
|
||||
require("mini.comment").setup({
|
||||
hooks = {
|
||||
pre = function()
|
||||
-- use treesitter commentstring functionality if it's installed
|
||||
if require("core.util").is_available("ts_context_commentstring") then
|
||||
require("ts_context_commentstring.internal").update_commentstring()
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
require("mini.cursorword").setup({ delay = 500 })
|
||||
vim.api.nvim_set_hl(0, "MiniCursorword", { bold = true, underline = false })
|
||||
vim.api.nvim_set_hl(0, "MiniCursorwordCurrent", { bold = true, underline = false })
|
||||
|
||||
require("mini.files").setup()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "MiniFilesWindowUpdate",
|
||||
callback = function(args)
|
||||
vim.wo[args.data.win_id].number = true
|
||||
end,
|
||||
})
|
||||
|
||||
require("mini.fuzzy").setup()
|
||||
require("mini.indentscope").setup({
|
||||
symbol = "│",
|
||||
draw = { animation = require("mini.indentscope").gen_animation.none() },
|
||||
options = { indent_at_cursor = false },
|
||||
})
|
||||
require("mini.map").setup()
|
||||
require("mini.move").setup()
|
||||
require("mini.operators").setup()
|
||||
require("mini.pairs").setup()
|
||||
require("mini.trailspace").setup()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
event = "VimEnter", -- need to load pretty soon for Starter screen
|
||||
keys = {
|
||||
{
|
||||
"<leader>sm",
|
||||
|
|
Loading…
Reference in a new issue