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
|
-- collection of plugins
|
||||||
{
|
{
|
||||||
"echasnovski/mini.nvim",
|
"echasnovski/mini.nvim",
|
||||||
version = "*",
|
dependencies = { "rktjmp/fwatch.nvim" }, -- for colorscheme updating
|
||||||
dependencies = { "rktjmp/fwatch.nvim" },
|
event = "VimEnter", -- need to load pretty soon for Starter screen
|
||||||
config = function()
|
config = function()
|
||||||
-- automatic callback to invoke 'mini.base16' when colorscheme file is changed
|
-- automatic callback to invoke 'mini.base16' when colorscheme file is changed
|
||||||
local colorsfile = vim.fn.stdpath("state") .. "/colorscheme.lua"
|
local colorsfile = vim.fn.stdpath("state") .. "/colorscheme.lua"
|
||||||
|
@ -112,6 +112,33 @@ return {
|
||||||
end),
|
end),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- this should be loaded as soon as the plugin is loaded
|
||||||
|
local starter = require("mini.starter")
|
||||||
|
starter.setup({
|
||||||
|
evaluate_single = true,
|
||||||
|
items = {
|
||||||
|
starter.sections.builtin_actions(),
|
||||||
|
{
|
||||||
|
name = "Scratchpad",
|
||||||
|
action = "lua require('personal.scratchpad').create()",
|
||||||
|
section = "Builtin actions",
|
||||||
|
},
|
||||||
|
starter.sections.recent_files(10, true),
|
||||||
|
starter.sections.recent_files(10, false),
|
||||||
|
-- Use this if you set up 'mini.sessions'
|
||||||
|
-- starter.sections.sessions(),
|
||||||
|
starter.sections.telescope(),
|
||||||
|
},
|
||||||
|
content_hooks = {
|
||||||
|
starter.gen_hook.adding_bullet(),
|
||||||
|
starter.gen_hook.padding(3, 2),
|
||||||
|
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()
|
require("mini.ai").setup()
|
||||||
-- Align tables and other alignable things
|
-- Align tables and other alignable things
|
||||||
require("mini.align").setup({})
|
require("mini.align").setup({})
|
||||||
|
@ -126,7 +153,7 @@ return {
|
||||||
indent = { suffix = "" }, -- disable since we use indentscope above
|
indent = { suffix = "" }, -- disable since we use indentscope above
|
||||||
jump = { suffix = "j", options = {} },
|
jump = { suffix = "j", options = {} },
|
||||||
location = { suffix = "l", options = {} },
|
location = { suffix = "l", options = {} },
|
||||||
oldfile = { suffix = "o", options = {} },
|
oldfile = { suffix = "o", options = {} }, -- FIXME: overwritten by wrapping defaults currently
|
||||||
quickfix = { suffix = "q", options = {} },
|
quickfix = { suffix = "q", options = {} },
|
||||||
treesitter = { suffix = "t", options = {} },
|
treesitter = { suffix = "t", options = {} },
|
||||||
undo = { suffix = "" }, -- disable since I don't need it
|
undo = { suffix = "" }, -- disable since I don't need it
|
||||||
|
@ -168,30 +195,9 @@ return {
|
||||||
require("mini.operators").setup()
|
require("mini.operators").setup()
|
||||||
require("mini.pairs").setup()
|
require("mini.pairs").setup()
|
||||||
require("mini.trailspace").setup()
|
require("mini.trailspace").setup()
|
||||||
local starter = require("mini.starter")
|
end,
|
||||||
starter.setup({
|
|
||||||
evaluate_single = true,
|
|
||||||
items = {
|
|
||||||
starter.sections.builtin_actions(),
|
|
||||||
{
|
|
||||||
name = "Scratchpad",
|
|
||||||
action = "lua require('personal.scratchpad').create()",
|
|
||||||
section = "Builtin actions",
|
|
||||||
},
|
|
||||||
starter.sections.recent_files(10, true),
|
|
||||||
starter.sections.recent_files(10, false),
|
|
||||||
-- Use this if you set up 'mini.sessions'
|
|
||||||
-- starter.sections.sessions(),
|
|
||||||
starter.sections.telescope(),
|
|
||||||
},
|
|
||||||
content_hooks = {
|
|
||||||
starter.gen_hook.adding_bullet(),
|
|
||||||
starter.gen_hook.padding(3, 2),
|
|
||||||
starter.gen_hook.aligning("center", "center"),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
event = "VimEnter", -- need to load pretty soon for Starter screen
|
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>sm",
|
"<leader>sm",
|
||||||
|
|
Loading…
Reference in a new issue