Ale: Errors when using ALEGetStatusLine() with airline

Created on 9 Oct 2016  路  14Comments  路  Source: dense-analysis/ale

Hi @w0rp, I may be wrong but I noticed that when i'm using ALEGetStatusLine() function with airline like this:
let g:airline_section_error = '%{ALEGetStatusLine()}'
then it works good for file types for which i have installed linters, but for other filetypes it throws errors:

E117: Unknown function: ALEGetStatusLine
E15: Invalid expression: ALEGetStatusLine()

I made a screencast with the actual behaviour https://asciinema.org/a/abbk4amukbzrvmgskyjesusd1

bug

Most helpful comment

@deathmaz Using airline helpers, it will look like:

call airline#parts#define_function('ALE', 'ALEGetStatusLine')
call airline#parts#define_condition('ALE', 'exists("*ALEGetStatusLine")')
let g:airline_section_error = airline#section#create_right(['ALE'])

@w0rp The code above should be included on the README (FAQ maybe?)

All 14 comments

I tried to repeat this myself with vim-airline, but I haven't had any luck so far. I did install airline for the first time in the process, which seems pretty cool.

@KabbAmine Do you want to have a look at this? I find the error there to be strange, as if something is deleting the function.

@w0rp Yeah, I'll check it when I will be at home.

@deathmaz Ok, tried with a minimal vimrc + ale + vim-airline and no issue so far.
Please do the same (Adapt the path):

vim -Nu <(cat << EOF
set rtp+=~/.vim/plugs/ale
set rtp+=~/.vim/plugs/vim-airline/
set rtp+=~/.vim/plugs/vim-airline-themes/

filetype plugin indent on
syntax enable

set laststatus=2
let g:airline_section_error = '%{ALEGetStatusLine()}'
EOF)

If the issue still occur, please provide a link to your configuration.

I found the problem
The thing is that i'm usin vim-plug as my plugin manager and for ale i have these settings:
Plug 'w0rp/ale', { 'for': ['javascript', 'php', 'css', 'scss', 'sass'] }
So I enabled ale just for file types for which i have linters installed
Are those errors expected bahaviour if the plugin is disabled but i have this line in my config:
let g:airline_section_error = '%{ALEGetStatusLine()}' ?

Ah, this is a configuration issue then. If you have only enabled ALE for those file types, the function won't exist for the other file types. You'll have to write an expression which checks if the function exists.

This might do the trick, but I haven't tested it:

let g:airline_section_error = '%{exists("ALEGetStatusLine") ? ALEGetStatusLine() : ""}'

If I remember well, there is a specific syntax for conditions in airline API, just check the doc.

There are plenty ways to solve your issue, choose the one you want:

  • Disable lazy loading for ale in plug config (By removing the for condition).
  • Create a function apart for airline:
function ALE() abort
    return exists('*ALEGetStatusLine') ? ALEGetStatusLine() : ''
endfunction
let g:airline_section_error = '%{ALE()}'
  • Use the airline's API (Check the doc).

Thank you guys for helping me with this! 馃憤
@KabbAmine, this solution works great:

function ALE() abort
    return exists('*ALEGetStatusLine') ? ALEGetStatusLine() : ''
endfunction
let g:airline_section_error = '%{ALE()}'

@deathmaz Using airline helpers, it will look like:

call airline#parts#define_function('ALE', 'ALEGetStatusLine')
call airline#parts#define_condition('ALE', 'exists("*ALEGetStatusLine")')
let g:airline_section_error = airline#section#create_right(['ALE'])

@w0rp The code above should be included on the README (FAQ maybe?)

Thanks! Sorry for bothering with not ale specific problems

This could go in an FAQ. I'll probably put it in one eventually. Thanks for the info!

Hi guys, today at the work i updated ale and noticed that it stops to show errors in airline errors section
Currently i'm on my home laptop and i made a screenshot before ale update (left side) and after (right side, always shows 0)
_2016-10-11_21-55-11

That would be my bug. I echoed where we need to return. The function was renamed to ale#statusline#Status() to facilitate autoloading, with the old name kept around for compatibilities sake. I have an open PR on the airline repo to add native ale support, which may interest you as well.

Great, thank you!

I just ran into something similar and this fixed it for me

Was this page helpful?
0 / 5 - 0 ratings