itchyny/lightline.vim

Returning a statusline item from a component function

mihaifm opened this issue · 2 comments

Hi and thanks for this great plugin!

Is there a way to return a statusline item from a component function?
For example, this doesn't work:

func! LightPercent()
   return '%P'
endfunc

It just displays %P in the statusline, instead of the percent. I can't set the component to %P directly because I want to have additional logic in the component function.

This is impossible. Use printf('%2d%%', line('.') * 100 / line('$')) for your case.

thanks