NIVM/lua/core/utils/lazy.lua
Robert Morrison fb537df11b chore(init): Initial working version
Create and push an initial working version of this repo before I change
things on this machine

Signed-off-by: Robert Morrison <robert@closedless.xyz>
2023-09-10 22:22:30 +01:00

34 lines
1.0 KiB
Lua

-- This function is taken from `asyncedd/dots.nvim`
-- From what I can tell this just ensures that some plugins load
-- in the "right" place. I may not need this but since I am basing my config off this one I will use it for now.
return function(plugin)
vim.api.nvim_create_autocmd({ 'BufRead', 'BufWinEnter', 'BufNewFile', 'WinEnter' }, {
callback = function()
if vim.fn.expand('%') ~= '' then
-- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename"
if plugin ~= 'nvim-treesitter' then
vim.schedule(function()
require('lazy').load { plugins = plugin }
if
plugin == 'nvim-lspconfig'
or plugin == 'null-ls.nvim'
or plugin == 'vim-matchup'
then
vim.cmd('silent! do FileType')
if plugin == 'null-ls.nvim' then
require('null-ls.state').register_conditional_sources()
end
end
end)
else
require('lazy').load { plugins = plugin }
end
end
end,
})
end