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",
|
"goolord/alpha-nvim",
|
||||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
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()
|
opts = function()
|
||||||
-- Set header
|
-- Set header
|
||||||
local header = {
|
local header = {
|
||||||
|
@ -15,12 +15,11 @@ return {
|
|||||||
-- Correctly hijack netrw, thanks to
|
-- Correctly hijack netrw, thanks to
|
||||||
-- https://github.com/nvim-neo-tree/neo-tree.nvim/issues/1247#issuecomment-1836294271
|
-- https://github.com/nvim-neo-tree/neo-tree.nvim/issues/1247#issuecomment-1836294271
|
||||||
vim.api.nvim_create_autocmd("BufEnter", {
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
group = vim.api.nvim_create_augroup("NeoTreeInit", { clear = true }),
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
local f = vim.fn.expand("%:p")
|
local f = vim.fn.expand("%:p")
|
||||||
if vim.fn.isdirectory(f) ~= 0 then
|
if vim.fn.isdirectory(f) == 1 then
|
||||||
require("neo-tree")
|
require("neo-tree")
|
||||||
-- neo-tree is loaded now, delete the init autocmd
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -122,15 +122,11 @@ return {
|
|||||||
"RRethy/nvim-treesitter-endwise",
|
"RRethy/nvim-treesitter-endwise",
|
||||||
},
|
},
|
||||||
init = function()
|
init = function()
|
||||||
vim.api.nvim_create_autocmd("BufEnter", {
|
vim.api.nvim_create_autocmd("FileReadPre", {
|
||||||
group = vim.api.nvim_create_augroup("NeoTreeInit", { clear = true }),
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
local f = vim.fn.expand("%:p")
|
require("nvim-treesitter")
|
||||||
if vim.fn.isdirectory(f) == 0 then
|
return true
|
||||||
require("neo-tree")
|
|
||||||
-- neo-tree is loaded now, delete the init autocmd
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user