Skip to content

Commit

Permalink
fix: mason extension lazy loading (#1196)
Browse files Browse the repository at this point in the history
Fixed mason extension to only load mason-registry when the lualine section is
displayed (on 'mason' filetype). This prevents loading mason when lualine is
loaded.
  • Loading branch information
trevarj authored Mar 15, 2024
1 parent 3e77976 commit af4c3cf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/lualine/extensions/mason.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
-- lualine extension for mason.nvim

local ok, mason_registry = pcall(require, 'mason-registry')
if not ok then
return ''
local mason_registry
local function maybe_set_registry()
local ok, registry = pcall(require, 'mason-registry')
if ok then
mason_registry = registry
end
end

local M = {}
Expand All @@ -15,6 +18,7 @@ M.sections = {
},
lualine_b = {
function()
maybe_set_registry()
return 'Installed: ' .. #mason_registry.get_installed_packages() .. '/' .. #mason_registry.get_all_package_specs()
end,
},
Expand Down

0 comments on commit af4c3cf

Please sign in to comment.