goolord / alpha-nvim

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

fix: Alpha crashes on startup #157

Closed KingEdwardI closed 1 year ago

KingEdwardI commented 1 year ago

Hi, I ran into an issue while trying to use your plugin. Some background - I started implementing/configuring it about a month ago, everything was fine at the time and I had to shelve it for a bit. Once I finally got back around to including it in my main config it started throwing these errors on startup (see attached screenshot & video). It's almost the same error as from #26, but this time it was throwing on multiple different calls. At first it seemed like some sort of conflict with git-conflict.nvim, but even after disabling that plugin Alpha still threw the same errors (I have since found a workaround to have both plugins work - just prevent git-conflict from loading on the dashboard screen). So after doing some digging, these changes fixed the issue for me. I really don't know if it's the best solution, I just based it off of your previous solution but I could imagine that this might just cover up a deeper problem. Please let me know if I've done something wrong or if there's a better way to solve this and I can make the according updates.

My current specs:

MacOS: 12.6 w/ 2.3 GHz, 8-core Intel i9, 32 Gig ram Neovim: 0.8.0 And my config, if it helps.

(Also, I tried to run stylua, but a lot of other files changed so I undid that)

Screen Shot 2022-11-18 at 5 15 16 PM

https://user-images.githubusercontent.com/20171781/202825241-536301c0-5b6a-4476-b9f2-3f51c567cc49.mp4 (The errors after everything loaded were from any keystroke)

And by the way, this is an awesome plugin - The configuration is really clean and I was able to do some pretty wild stuff with the dashboard image.

KingEdwardI commented 1 year ago

Oh my golly gosh goodness, I'm a fool. I had other issues in my config, I forgot how vimscript worked. :facepalm:. Sorry to bother you.

For posterity, my issue was this:

function OpenAlpha()
    let cnt = 0
    for i in range(0, bufnr("$"))
        if buflisted(i)
---         cnt = cnt + 1
+++         let cnt = cnt + 1
        endif
    endfor
    if cnt <= 1
      Alpha
    endif
endfunction

and

--- autocmd BufDelete * if empty(&filetype) | execute OpenAlpha()
+++ autocmd BufDelete * if !empty(&filetype) | execute OpenAlpha()