Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when using ALEGetStatusLine() with airline #71

Closed
deathmaz opened this issue Oct 9, 2016 · 14 comments
Closed

Errors when using ALEGetStatusLine() with airline #71

deathmaz opened this issue Oct 9, 2016 · 14 comments
Labels

Comments

@deathmaz
Copy link
Contributor

deathmaz commented Oct 9, 2016

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

@w0rp w0rp added the bug label Oct 9, 2016
@w0rp
Copy link
Member

w0rp commented Oct 9, 2016

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.

@KabbAmine
Copy link
Contributor

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

@KabbAmine
Copy link
Contributor

@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.

@deathmaz
Copy link
Contributor Author

deathmaz commented Oct 9, 2016

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()}' ?

@w0rp
Copy link
Member

w0rp commented Oct 9, 2016

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() : ""}'

@KabbAmine
Copy link
Contributor

KabbAmine commented Oct 9, 2016

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).

@deathmaz
Copy link
Contributor Author

deathmaz commented Oct 9, 2016

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 deathmaz closed this as completed Oct 9, 2016
@KabbAmine
Copy link
Contributor

KabbAmine commented Oct 9, 2016

@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?)

@deathmaz
Copy link
Contributor Author

deathmaz commented Oct 9, 2016

Thanks! Sorry for bothering with not ale specific problems

@w0rp
Copy link
Member

w0rp commented Oct 9, 2016

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

@deathmaz
Copy link
Contributor Author

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

@deathmaz deathmaz reopened this Oct 11, 2016
@neersighted
Copy link
Member

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.

@w0rp w0rp closed this as completed in #95 Oct 11, 2016
w0rp added a commit that referenced this issue Oct 11, 2016
Return in the statusline compatibility function, fixing #71
@deathmaz
Copy link
Contributor Author

Great, thank you!

machupicchubeta added a commit to machupicchubeta/dotfiles that referenced this issue Aug 15, 2018
machupicchubeta added a commit to machupicchubeta/dotfiles that referenced this issue Aug 15, 2018
It seems that `ALEGetStatusLine` became deprecated.
Instead, I can use `lightline-ale`.

See also:
- dense-analysis/ale#71 (comment)
- https://sinshutu-kibotu.hatenablog.jp/entry/2018/06/24/025319
- https://github.com/maximbaz/lightline-ale
caulagi added a commit to caulagi/dotfiles that referenced this issue Dec 2, 2018
@robophil
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants