nvimdev / dashboard-nvim

vim dashboard
MIT License
2.3k stars 187 forks source link

Theme doom's content not vertically centered #354

Open xfdj opened 1 year ago

xfdj commented 1 year ago

Describe the bug

My config:

return {
    "glepnir/dashboard-nvim",
    event = "VimEnter",
    config = function()
        require("dashboard").setup({
            theme = "doom",
        })
    end,
    dependencies = { { "nvim-tree/nvim-web-devicons" } },
}

The content goes to the top of my window, not the center of it.

image

Theme hyper is correct:

return {
    "glepnir/dashboard-nvim",
    event = "VimEnter",
    config = function()
        require("dashboard").setup({
            theme = "hyper",
        })
    end,
    dependencies = { { "nvim-tree/nvim-web-devicons" } },
}

image

I wonder if it is because the code below is missing in function theme_instance in lua/dashboard/theme/doom.lua:

    local size = math.floor(vim.o.lines / 2)
      - math.ceil(api.nvim_buf_line_count(config.bufnr) / 2)
      - 2
    local fill = utils.generate_empty_table(size)
    api.nvim_buf_set_lines(config.bufnr, 0, 0, false, fill)

I found the code in theme hyper's file. I don't know if it is a bug or a feature.

PS: Forgive my poor English.

To Reproduce

Expected behavior

Screenshots

glepnir commented 1 year ago

please waiting for next version

xfdj commented 1 year ago

Thank you!

UtkarshVerma commented 7 months ago

I would also love to see this. Any updates?

TomLebeda commented 6 months ago

I'm also interested in this issue, here is one small thing I noticed, maybe it will help:

I tried to add empty lines at the top of my logo in attempt to temporarily fix the centering issue, but it doesn't have any effect. But when I open some files and then use the Dashboard command to come back, then it looks correct.

Also it behaves differently in Alacritty and in Wezterm. In Alacritty, the empty lines helped.

nammenam commented 1 month ago

You can inject spaces into the header itself to get this behavior but it is kinda hacky

local api = vim.api

local function generate_empty_lines(size)
    local fill = {}
    for _ = 1, size do
        table.insert(fill, "")
    end
    return fill
end

local function center_header(header)
    local size = math.floor(vim.o.lines / 2)
        - math.ceil(#header / 2)
        - 2
    local fill = generate_empty_lines(size)
    return vim.list_extend(fill, header)
end

local header_content = {
  [[                                   ]],
  [[            header                 ]],
  [[                                   ]],
}

return {
    {
        'nvimdev/dashboard-nvim',
        event = 'VimEnter',
        config = function()
            require('dashboard').setup({
                theme = 'doom',
                config = {
                    header = center_header(header_content),
                    ...

Screenshot_2024-07-31_23-20-52

polirritmico commented 4 weeks ago

I've made a PR #476 for this, but I think it needs more testing. Could someone please check it?