diff --git a/README.md b/README.md index 2905121..3bb2009 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ dashboard will use default highlight group like `DashboardKey/Icon/Desc` instead - `Dashboard` open dashboard - `DbProjectDelete count` delete project in cache works for hyper theme. count is number +- `DashboardUpdateFooter` updates the content of the Footer ### Highlight diff --git a/lua/dashboard/theme/doom.lua b/lua/dashboard/theme/doom.lua index 8a85b21..f5f0020 100644 --- a/lua/dashboard/theme/doom.lua +++ b/lua/dashboard/theme/doom.lua @@ -193,6 +193,8 @@ local function generate_footer(config) for i = 1, #footer do api.nvim_buf_add_highlight(config.bufnr, 0, 'DashboardFooter', first_line + i - 1, 0, -1) end + + utils.add_update_footer_command(config.bufnr, footer) end ---@private diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 68417f4..1e46b95 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -460,6 +460,8 @@ local function gen_footer(config) for i, _ in pairs(footer) do api.nvim_buf_add_highlight(config.bufnr, 0, 'DashboardFooter', first_line + i - 1, 0, -1) end + + utils.add_update_footer_command(config.bufnr, footer) end local function project_delete() diff --git a/lua/dashboard/utils.lua b/lua/dashboard/utils.lua index e32c0fb..41a8a90 100644 --- a/lua/dashboard/utils.lua +++ b/lua/dashboard/utils.lua @@ -172,4 +172,25 @@ function utils.buf_is_empty(bufnr) and vim.api.nvim_buf_get_lines(0, 0, -1, false)[1] == '' end +local last_footer_size = nil +function utils.add_update_footer_command(bufnr, footer) + vim.api.nvim_create_user_command('DashboardUpdateFooter', function(args) + if last_footer_size == nil then + last_footer_size = #footer + end + + local first_line = vim.api.nvim_buf_line_count(bufnr) + vim.api.nvim_buf_set_lines( + bufnr, + first_line - last_footer_size, + -1, + false, + utils.center_align(args.fargs) + ) + vim.bo[bufnr].modified = false + + last_footer_size = #args.fargs -- For future calculation of size + end, { nargs = '*' }) +end + return utils