refactor(nvim): improve lazy loading of alpha, treesitter, & neo-tree

This commit is contained in:
Price Hiller 2024-02-19 08:05:22 -06:00
parent a6996bb086
commit 2ac83cc7ad
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
3 changed files with 19 additions and 11 deletions

View File

@ -2,6 +2,19 @@ return {
{
"goolord/alpha-nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
init = function()
vim.api.nvim_create_autocmd("BufEnter", {
once = true,
callback = function()
local f = vim.fn.expand("%:p")
if vim.fn.isdirectory(f) == 0 then
require("alpha")
return true
end
end,
})
end,
lazy = true,
opts = function()
-- Set header
local header = {

View File

@ -15,12 +15,11 @@ return {
-- Correctly hijack netrw, thanks to
-- https://github.com/nvim-neo-tree/neo-tree.nvim/issues/1247#issuecomment-1836294271
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("NeoTreeInit", { clear = true }),
once = true,
callback = function()
local f = vim.fn.expand("%:p")
if vim.fn.isdirectory(f) ~= 0 then
if vim.fn.isdirectory(f) == 1 then
require("neo-tree")
-- neo-tree is loaded now, delete the init autocmd
return true
end
end,

View File

@ -122,15 +122,11 @@ return {
"RRethy/nvim-treesitter-endwise",
},
init = function()
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("NeoTreeInit", { clear = true }),
vim.api.nvim_create_autocmd("FileReadPre", {
once = true,
callback = function()
local f = vim.fn.expand("%:p")
if vim.fn.isdirectory(f) == 0 then
require("neo-tree")
-- neo-tree is loaded now, delete the init autocmd
return true
end
require("nvim-treesitter")
return true
end,
})
end,