lightline.vim
A light and configurable statusline for Vim
https://github.com/itchyny/lightline.vim
powerline theme (default)
wombat (with the patched font)
jellybeans (with the patched font)
solarized theme (dark)
solarized theme (light)
landscape theme (with the patched font)
With branch name, read-only mark and modified mark.

landscape is my colorscheme, which is a high-contrast cui-supported colorscheme, available at https://github.com/itchyny/landscape.vim
Why yet another clone of powerline?
- vim-powerline is a nice plugin, but deprecated.
- powerline is a nice plugin, but difficult to configure.
- vim-airline is a nice plugin, but not configurable. Also, it does too much for other plugins, which should be done by users in .vimrc.
Spirit of this plugin
- Minimalism. The core script is very small.
- Configurability. You can create your own component and easily add to the statusline.
- Orthogonality. Any plugin should not change the settings of another plugin. Such a plugin-crossing setting should be written by users in
.vimrc.
Author
itchyny (https://github.com/itchyny)
License
MIT License
Installation
Manually
- Put all files under $VIM.
Vundle (https://github.com/gmarik/vundle)
-
Add the following configuration to your .vimrc.
Bundle 'itchyny/lightline.vim' -
Install with
:BundleInstall.
NeoBundle (https://github.com/Shougo/neobundle.vim)
-
Add the following configuration to your .vimrc.
NeoBundle 'itchyny/lightline.vim' -
Install with
:NeoBundleInstall.
Configuration tutorial
In default, the statusline looks like:
If you want a colorscheme which looks well with the wombat colorscheme, add the following setting to your .vimrc (or _vimrc on Windows):
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
You may think that the default read-only mark is not so cool:
Then edit the readonly component.
The lightline components are stored in g:lightline.component.
So you add the setting of g:lightline.component.readonly in your .vimrc. (the following setting is effective with the patched font for vim-powerline):
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"⭤":""}',
\ }
\ }
But the boundaries are quadrilateral. You may miss the powerline. You have installed a cool font for powerlines, so you can use it.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"⭤":""}',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
Now, you look into a help file to find the marks annoying.
Help files are read-only and no-modifiable? We know that!
OK, so you again edit your .vimrc.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
Huh? Weird!
The component does not collapse even if it has no information!
In order to avoid this situation, you set expressions to component_visible_condition, which should become 1 only when the corresponding components have information.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
How does lightline deside the components to show in the statusline?
It's very simple.
The variable to control the components is g:lightline.active.left and g:lightline.active.left.
For example, you add the g:lightline.active.left in .vimrc.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
The plugin arranges all the component:
The mode component, the paste component, read-only component, filename component and modified component in a row.
Normally, the paste component does not show up.
If the file is not read-only (more common cases), the read-only component does not show up.

Again look into g:lightline.active.left.
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ] ...
And the screen shot of all the components.
The mode and paste component are displayed in the same group.
And the read-only, filename and modified component are in the second group.
It corresponds to the structure of g:lightline.active.left.
GitHub branch is important for us. And it is a default component in powerline. However, lightline does not provide the branch feature in default.
In order to show the branch in statusline, you firstly install the vim-fugitive plugin.
Then edit the g:lightline in your .vimrc.
- Add fugitive component to
g:lightline.component. - Add the condition when the fugitive component has information to
g:lightline.component_visible_condition. - Add the component by inserting 'fugitive' to
g:lightline.active.left.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
Okay, the branch component is added!
Now, you might get tired of setting both 'component' and 'component_visible_condition'.
Or if you want to do something more complicated?
In fact, the components can be created using functions.
Add your function names for components to g:lightline.component_function.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'MyFugitive',
\ 'readonly': 'MyReadonly',
\ 'modified': 'MyModified'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! MyModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! MyReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "⭤"
else
return ""
endif
endfunction
function! MyFugitive()
return exists('*fugitive#head') ? fugitive#head()
endfunction
Finally, you come up with concatenating the three components: the read-only mark, the filename and the modified mark. Now you may know what to do.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'MyFugitive',
\ 'readonly': 'MyReadonly',
\ 'modified': 'MyModified',
\ 'filename': 'MyFilename'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! MyModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! MyReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "⭤"
else
return ""
endif
endfunction
function! MyFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
function! MyFilename()
return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ ('' != expand('%t') ? expand('%t') : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
Define your own filename component. Your component has priority over the default component.
Oops! We forgot the cool mark for the branch component! (work with the patched font for vim-powerline)
function! MyFugitive()
return exists('*fugitive#head') && len(fugitive#head()) ? '⭠ '.fugitive#head() : ''
endfunction
Of course, you can name your component as you wish.
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'my_filename' ] ] },
\ 'component_function': {
\ 'my_filename': 'MyFilename', ...
This is the end of the tutorial. For more information, see :help lightline. Good luck with your nice statuslines.
My setting
Here's my setting. I use the patched font for vim-powerline.
let g:lightline = {
\ 'colorscheme': 'landscape',
\ 'mode_map': { 'c': 'NORMAL' },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'MyModified',
\ 'readonly': 'MyReadonly',
\ 'fugitive': 'MyFugitive',
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! MyModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &ro ? '⭤' : ''
endfunction
function! MyFilename()
return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? substitute(b:vimshell.current_dir,expand('~'),'~','') :
\ '' != expand('%t') ? expand('%t') : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
function! MyFugitive()
return &ft !~? 'vimfiler\|gundo' && exists('*fugitive#head') && len(fugitive#head()) ? '⭠ '.fugitive#head() : ''
endfunction
function! MyFileformat()
return winwidth('.') > 60 ? &fileformat : ''
endfunction
function! MyFiletype()
return winwidth('.') > 60 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth('.') > 60 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MyMode()
return winwidth('.') > 60 ? lightline#mode() : ''
endfunction
When the window width is too narrow, the mode component and the file information component collapse. For example, the gundo buffer is narrow.
Nice looking, isn't it?



























