Ale: How to get this to work in lightline

Created on 21 Apr 2017  Â·  8Comments  Â·  Source: dense-analysis/ale

Was following some of the suggestions here https://github.com/w0rp/ale/issues/279

In .vimrc, I have

let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']

let g:lightline = {
\    'colorscheme': 'powerline',
\    'active': {
\      'left': [ [ 'mode',  'ale' ], [ 'filename' ], ['modified'] ],
\      'right': []
\    },
\    'inactive': {
\      'left': [ [ 'filename' ], ['modified'] ],
\      'right': []
\    },
\    'mode_map': {
\      'n' : '[n]',
\      'i' : '{i}',
\      'R' : '/r/',
\      'v' : '(v)',
\      'V' : '(v)',
\      "\<C-v>": '(v)',
\      's' : '|s|',
\      'S' : '|s|',
\      "\<C-s>": '|s|'
\    },
\    'component_expand': {
\      'ale': 'LightLineAle'
\    },
\    'component_function': {
\      'filename': 'RelativePathToFilename'
\    }
\  }

function! LightLineAle()
  return winwidth(0) > 90 && &ft !~? s:except_ft && exists("*ALEGetStatusLine") ?
    \ ALEGetStatusLine() : ''
  endif
endfunction

augroup UpdateAleLightLine
  autocmd!
  autocmd User ALELint call lightline#update()
augroup END

I cant seem to see the ale status in lightline. Any feedback would be appreciated

Most helpful comment

I just got this to work with help from the author of lightline: https://github.com/itchyny/lightline.vim/issues/236

All 8 comments

I don't know much about lightline configuration myself, but I'm sure there will be another user who might know more. I'll have a look into this eventually if no one else is sure either.

I'll recommend using the other function for getting the status that ALEGetStatusLine uses. I'd like to remove that function eventually.

Which function would that be?

Btw, seems to work without the ternary condition. i.e. just having return ALEGetStatusLine()

FYI, here is my setting for Lightline + ALE. https://github.com/delphinus/lightline-delphinus

I want to show status in different color in OK or Warning or Error, and so I needed to write a bit complex functions to achieve that.

@krzkrzkrz This is how that function is defined:

function! ALEGetStatusLine() abort
    return ale#statusline#Status()
endfunction

I recommend calling ale#statusline#Status() instead. I probably won't remove the former function for a long time, but I will remove it eventually. It's just there for supporting old vimrc configurations from people.

I just got this to work with help from the author of lightline: https://github.com/itchyny/lightline.vim/issues/236

Cool. :+1:

Was this page helpful?
0 / 5 - 0 ratings