How to show full file path in LightLine

LightLine is a lightweight statusline plugin for Vim. By default, it shows only the filename on the left side of the statusbar. I like to have the full file path displayed instead. It turns out that is easy to do.

The statusline has many components, and the component that shows the filename is called filename. We override this in LightLine with a tiny function that uses the expand function in Vim to get the full file path.

I added these lines in Vim to achieve this:

" Replace filename component of Lightline statusline
let g:lightline = {
      \ 'component_function': {
      \   'filename': 'FilenameForLightline'
      \ }
      \ }

" Show full path of filename
function! FilenameForLightline()
    return expand('%')
endfunction

Tried with: Vim 7.4 and Ubuntu 16.04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s