Vim-airline: Setting Themes Doesn't Work

Created on 5 Jul 2013  路  21Comments  路  Source: vim-airline/vim-airline

let s:load_the_theme = g:airline#themes#{g:airline_theme}#normal is not a valid vim expression apparently.

Error detected while processing /usr/share/vim/vimfiles/plugin/airline.vim:
line   25:
E121: Undefined variable: g:airline#themes#default#normal
E15: Invalid expression: g:airline#themes#{g:airline_theme}#normal
Press ENTER or type command to continue

Most helpful comment

Can I just confirm that the setting has to be a string name? (e.g.)

let g:airline_theme='wombat'

Of a file from the themes directory (e.g.)

ls ~/.vim/bundle/vim-airline/autoload/airline/themes

All 21 comments

what value did you set g:airline_theme to? it has to match one of the files under autoload/airline/themes

edit: it looks like you set it to 'default'. the default theme was renamed to dark a couple commits ago.

Ah. My bad.

Weirdly enough, it's not loading anymore after setting the theme properly.

not loading at all, or not loading until you split (#20).

It loads right after I split.

duplicate of #20.

Can I just confirm that the setting has to be a string name? (e.g.)

let g:airline_theme='wombat'

Of a file from the themes directory (e.g.)

ls ~/.vim/bundle/vim-airline/autoload/airline/themes

just the name of the theme.

just the name of the theme.

That contradicts the instructions in the wiki. The setting only worked for me with the theme name as a string.

Worked for me:

:let g:airline_theme='powerlineish'

Didn't work:

:let g:airline_theme=powerlineish

Also did work for me :
:let g:airline_theme:'powerlineish'
And didn't work:
:let g:airline_theme:powerlineish
This is an example, I did it with another theme

Until I added let g:airline_theme='dark' to my .vimrc, I was getting the following error every time I opened vim:

Error detected while processing function <SNR>22_on_window_changed..<SNR>22_init:
line   14:
E121: Undefined variable: g:airline_theme
E15: Invalid expression: 'Could not resolve airline theme "' . g:airline_theme . '". Themes have been migrated to github.com/vim-airline/vim-airline-themes.'

jonorthwash,
You need to install the vim-airline-themes either manually or through your plugin manager to be able to use a theme other than dark with vim-airline as dark is the only theme that comes with vim-airline by default.

I had no reference to the theme in my .vimrc, as I simply followed the installation instructions for pathogen listed on the airline page.

Perhaps I should restate my comment as "After following pathogen installation instructions it gave the error messages [above] until I manually specified a theme." I would have expected it to fall back to the default theme when one wasn't specified (which seems to be what you expect too, but I can't really tell), but instead it gave those errors.

jonorthwash,
The error you gave specifically mentions line 14 of your .vimrc.
Most likely that you had the setting in your .vimrc improperly defined or an improper installation of vim-airline. Or could just be a strange bug. I have tested the plugin myself with no theme setting in my .vimrc and have faced no issue.
Might be able to tell if I could have a look at your actual .vimrc before you had made the change. Preferably in a pastebin if you do decide to share your full .vimrc or on a github repo itself.
Do keep in mind I am not a dev or an expert on the topic so could be completely wrong about what's causing the issue.

My current .vimrc: https://bpaste.net/show/867b8a71792d

Note that all the stuff at the bottom is very recent, and I'm playing with some of it to try to solve other problems with airline.

jonorthwash,
Try commenting out the "let g:airline_theme='powerlineish'" line and see if vim spits out an error when you start it.
If there is no error then it's likely that there was a mistake you may have missed in a previous iteration of your .vimrc.
If there is an error then it could possibly be caused by your sourcing on line 27 "source ~/.vim/comments.vim"

Yep, it does this now (when I comment out the theme line):

Error detected while processing function <SNR>22_on_window_changed..<SNR>22_init
:
line   14:
E121: Undefined variable: g:airline_theme
E15: Invalid expression: 'Could not resolve airline theme "' . g:airline_theme .
 '". Themes have been migrated to github.com/vim-airline/vim-airline-themes.'
Press ENTER or type command to continue

As I said before, I get this sort of error when I don't have a theme specified. And no, commenting out the comments.vim line doesn't make a difference.

The installation instructions should probably be adjusted to mention that a theme needs to be specified.

jonorthwash,
Any possibility of it being caused by line 27 "source ~/.vim/comments.vim"?
Otherwise the only difference between my configuration and yours is the plugin managers we are using. I am using vim-plug by junegunn, if you really want to get to the bottom of this issue you could try this plugin manager and see if it fixes the issue.
You might like it better than Pathogen, I personally do. Do keep in mind that even though the issue may disappear after trying vim-plug that doesn't necessarily mean that the issue is with Pathogen itself.
If switching plugin managers doesn't fix the issue then it goes beyond my knowledge but at least it's an easily fixed problem.

Hi Jonathan!

On Mi, 03 Feb 2016, Jonathan Washington wrote:

Yep, it does this now (when I comment out the theme line):

Error detected while processing function <SNR>22_on_window_changed..<SNR>22_init
:
line   14:
E121: Undefined variable: g:airline_theme
E15: Invalid expression: 'Could not resolve airline theme "' . g:airline_theme .
 '". Themes have been migrated to github.com/vim-airline/vim-airline-themes.'
Press ENTER or type command to continue

As I said before, I get this sort of error when I don't have a theme specified.

You seem to have not the most recent version of airline installed.
Please pull the latest version and try again.

Aha, it doesn't complain now when no theme is specified, and appear to load the dark theme. I guess I should've specified which revision I was using, but it was quite recent (commit d7fd8ca - I basically posted my original comment within a few hours of pulling). Anyway, thanks for pointing me to a fix!

My set is:

let g:AirlineTheme='base16_colors'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tnguyen14 picture tnguyen14  路  24Comments

sekoenig-de picture sekoenig-de  路  19Comments

jaredcobb picture jaredcobb  路  36Comments

a14m picture a14m  路  44Comments

zdm picture zdm  路  46Comments