Skip to content

Commit

Permalink
perf: improve performance of triggered plugin loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Apr 1, 2024
1 parent cfdfe91 commit bae0ad7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lua/astronvim/plugins/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ return {
"jay-babu/mason-nvim-dap.nvim",
dependencies = { "nvim-dap" },
init = function()
require("astrocore").on_load("mason.nvim", function() require "mason-nvim-dap" end)
require("astrocore").on_load(
"mason.nvim",
function() require("lazy").load { plugins = { "mason-nvim-dap.nvim" } } end
)
end,
cmd = { "DapInstall", "DapUninstall" },
opts = { handlers = {} },
Expand Down
10 changes: 8 additions & 2 deletions lua/astronvim/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ return {
"williamboman/mason-lspconfig.nvim",
cmd = { "LspInstall", "LspUninstall" },
init = function()
require("astrocore").on_load("mason.nvim", function() require "mason-lspconfig" end)
require("astrocore").on_load(
"mason.nvim",
function() require("lazy").load { plugins = { "mason-lspconfig.nvim" } } end
)
end,
opts = function(_, opts)
if not opts.handlers then opts.handlers = {} end
Expand Down Expand Up @@ -50,7 +53,10 @@ return {
"jay-babu/mason-null-ls.nvim",
cmd = { "NullLsInstall", "NullLsUninstall" },
init = function()
require("astrocore").on_load("mason.nvim", function() require "mason-null-ls" end)
require("astrocore").on_load(
"mason.nvim",
function() require("lazy").load { plugins = { "mason-null-ls.nvim" } } end
)
end,
opts = { handlers = {} },
},
Expand Down
2 changes: 1 addition & 1 deletion lua/astronvim/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ return {
local stats = (vim.uv or vim.loop).fs_stat(vim.api.nvim_buf_get_name(0)) -- TODO: REMOVE vim.loop WHEN DROPPING SUPPORT FOR Neovim v0.9
if stats and stats.type == "directory" then
vim.api.nvim_del_augroup_by_name "neotree_start"
require "neo-tree"
require("lazy").load { plugins = { "neo-tree.nvim" } }
end
end
end,
Expand Down
5 changes: 3 additions & 2 deletions lua/astronvim/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ return {
max_height = function() return math.floor(vim.o.lines * 0.75) end,
max_width = function() return math.floor(vim.o.columns * 0.75) end,
on_open = function(win)
local astrocore = require "astrocore"
vim.api.nvim_win_set_config(win, { zindex = 175 })
if not require("astrocore").config.features.notifications then vim.api.nvim_win_close(win, true) end
if not package.loaded["nvim-treesitter"] then pcall(require, "nvim-treesitter") end
if not astrocore.config.features.notifications then vim.api.nvim_win_close(win, true) end
if astrocore.is_available "nvim-treesitter" then require("lazy").load { plugins = { "nvim-treesitter" } } end
vim.wo[win].conceallevel = 3
local buf = vim.api.nvim_win_get_buf(win)
if not pcall(vim.treesitter.start, buf, "markdown") then vim.bo[buf].syntax = "markdown" end
Expand Down

0 comments on commit bae0ad7

Please sign in to comment.