goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.82k stars 109 forks source link

Neovide startup issue #150

Closed xbladesub closed 1 year ago

xbladesub commented 1 year ago

I have an issue with neovide, thins happens on start but goes away after I open any other buffer or telescope window. Is there any way to fix that?

Screen Shot 2022-10-04 at 6 57 13 PM
jedrzejboczar commented 1 year ago

I noticed the same issue and after some debugging I found that the issue was in implementation of my custom top padding element. I used something like:

local top_padding = function(height_estimate)
    return function()
        local height = vim.api.nvim_win_get_height(0)  -- <= this was using current window
        local calculated = (height - height_estimate) / 2
        return math.ceil(math.max(1, calculated))
    end
end

local layout = {
    { type = 'padding', val = top_padding(50) },
    -- ...
}

So it was checking the current window height, which for a telescope window was of course incorrect. A simple fix was to check current buffer filetype and use the previous padding value:

local top_padding = function(height_estimate)
    local cached
    return function()
        -- Use cached value if redrawing from another window
        local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
        if cached and filetype ~= 'alpha' then
            return cached
        end
        local height = vim.api.nvim_win_get_height(0)
        local calculated = (height - height_estimate) / 2
        cached = math.ceil(math.max(1, calculated))
        return cached
    end
end
xbladesub commented 1 year ago

@jedrzejboczar where do you use 'layout' property?

jedrzejboczar commented 1 year ago

I'm not using the presets but defining layout using this setting, so it's require('alpha').setup { layout = ... }. If you're using a default theme than it's defining the layout, e.g. dashboard.

xbladesub commented 1 year ago

@jedrzejboczar still have this issue while using this fn for padding.. but it's definitely padding issue - displays normal with padding 0, but looks weird :)

xbladesub commented 1 year ago

Solved by adding empty lines to my ASCII logo 😆