goolord / alpha-nvim

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

Startify theme: attempt to index a nil value #8

Closed JanValiska closed 3 years ago

JanValiska commented 3 years ago

Hi,

when I configure alpha to use startify theme:

    use {
        'goolord/alpha-nvim',
        config = function()
            require'alpha'.setup(require'alpha.themes.startify'.opts)
        end
    }

I get error on startup:

packer.nvim: Error running config for alpha-nvim: ...ck/packer/start/alpha-nvim/lua/alpha/themes/startify.lua:64: attempt to index a nil value

Any idea how to solve? Thanks

JanValiska commented 3 years ago

I printed oldfiles using print(vim.inspect(oldfiles)) and what I can say is that in the history there is one non-text(binary) file that I accidentally opened yesterday. Maybe it is needed to handle binary files in the history separately. I suppose that there is missing icon for binary files.

JanValiska commented 3 years ago

So it looks like problem aren't binary files but files without extension. Since you are matching filename fn:match("^.+(%..+)$"):sub(2) and supposing that there is always match.

JanValiska commented 3 years ago

Something like this:

            local match = fn:match("^.+(%..+)$") 
            local ext = ''
            if match ~= nil then
                ext = match:sub(2)
            end

solves issue and uses default web-dev icon for files without extension.

goolord commented 3 years ago

hmm i fixed this already but it got clobbered somehow. i will push a fix for this

goolord commented 3 years ago

should be fixed in https://github.com/goolord/alpha-nvim/commit/2e6ef7cf5ed79e63e04bb625ef5dedb8c90de919