Skip to content

Commit

Permalink
feat: added additional plugins info when using lazy.nvim (#370)
Browse files Browse the repository at this point in the history
missing hash character

Co-authored-by: Raphael <glephunter@gmail.com>
  • Loading branch information
agoodshort and glepnir authored Jul 26, 2023
1 parent ab84915 commit f57f905
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
20 changes: 19 additions & 1 deletion lua/dashboard/theme/doom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,25 @@ end

local function generate_footer(config)
local first_line = api.nvim_buf_line_count(config.bufnr)
local footer = { '', '', 'neovim loaded ' .. utils.get_packages_count() .. ' packages' }
local package_manager_stats = utils.get_package_manager_stats()
local footer = {}
if package_manager_stats.name == 'lazy' then
footer = {
'',
'',
'Startuptime: ' .. package_manager_stats.time .. ' ms',
'Plugins: '
.. package_manager_stats.loaded
.. ' loaded / '
.. package_manager_stats.count
.. ' installed',
}
else
footer = {
'',
'neovim loaded ' .. package_manager_stats.count .. ' plugins',
}
end
if config.footer then
if type(config.footer) == 'function' then
footer = config.footer()
Expand Down
22 changes: 18 additions & 4 deletions lua/dashboard/theme/hyper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,24 @@ local function load_packages(config)
return
end

local lines = {
'',
'neovim loaded ' .. utils.get_packages_count() .. ' packages',
}
local package_manager_stats = utils.get_package_manager_stats()
local lines = {}
if package_manager_stats.name == 'lazy' then
lines = {
'',
'Startuptime: ' .. package_manager_stats.time .. ' ms',
'Plugins: '
.. package_manager_stats.loaded
.. ' loaded / '
.. package_manager_stats.count
.. ' installed',
}
else
lines = {
'',
'neovim loaded ' .. package_manager_stats.count .. ' plugins',
}
end

local first_line = api.nvim_buf_line_count(config.bufnr)
api.nvim_buf_set_lines(config.bufnr, first_line, -1, false, utils.center_align(lines))
Expand Down
14 changes: 9 additions & 5 deletions lua/dashboard/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,22 @@ function utils.get_mru_list()
return mru
end

function utils.get_packages_count()
local count = 0
function utils.get_package_manager_stats()
local package_manager_stats = { name = '', count = 0, loaded = 0, time = 0 }
---@diagnostic disable-next-line: undefined-global
if packer_plugins then
package_manager_stats.name = 'packer'
---@diagnostic disable-next-line: undefined-global
count = #vim.tbl_keys(packer_plugins)
package_manager_stats.count = #vim.tbl_keys(packer_plugins)
end
local status, lazy = pcall(require, 'lazy')
if status then
count = lazy.stats().count
package_manager_stats.name = 'lazy'
package_manager_stats.loaded = lazy.stats().loaded
package_manager_stats.count = lazy.stats().count
package_manager_stats.time = lazy.stats().startuptime
end
return count
return package_manager_stats
end

--- generate an empty table by length
Expand Down

0 comments on commit f57f905

Please sign in to comment.