refactor(nvim): improve lazy loading of alpha, treesitter, & neo-tree
This commit is contained in:
parent
a6996bb086
commit
2ac83cc7ad
@ -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 = {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user