Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme doom's content not vertically centered #354

Open
xfdj opened this issue May 3, 2023 · 6 comments · May be fixed by #476
Open

Theme doom's content not vertically centered #354

xfdj opened this issue May 3, 2023 · 6 comments · May be fixed by #476

Comments

@xfdj
Copy link

xfdj commented May 3, 2023

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
Copy link
Member

glepnir commented May 4, 2023

please waiting for next version

@xfdj
Copy link
Author

xfdj commented May 5, 2023

Thank you!

@UtkarshVerma
Copy link

I would also love to see this. Any updates?

@TomLebeda
Copy link

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
Copy link

nammenam commented Jul 31, 2024

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants