2013-08-22 15:48:35 +09:00
2013-08-22 14:36:29 +09:00
2013-08-22 04:57:49 +09:00
2013-08-22 15:47:35 +09:00

lightline.vim

A light and configurable statusline for Vim

powerline theme (default)

lightline.vim - powerline - normal lightline.vim - powerline - insert lightline.vim - powerline - visual lightline.vim - powerline - replace

wombat (with font integration)

lightline.vim - wombat - normal lightline.vim - wombat - insert lightline.vim - wombat - visual lightline.vim - wombat - replace

solarized theme (dark)

lightline.vim - solarized_dark - normal lightline.vim - solarized_dark - insert lightline.vim - solarized_dark - visual lightline.vim - solarized_dark - replace

solarized theme (light)

lightline.vim - solarized_light - normal lightline.vim - solarized_light - insert lightline.vim - solarized_light - visual lightline.vim - solarized_light - replace

landscape theme (with font integration)

lightline.vim - landscape - normal lightline.vim - landscape - insert lightline.vim - landscape - visual lightline.vim - landscape - replace With branch name, readonly mark and modified mark. lightline.vim - landscape - fugitive

Why yet another...?

  • vim-powerline is a nice plugin, but deprecated.
  • vim-airline is a nice plugin, but not configurable. Also, it does too much for other plugins, which should be done by uesrs in .vimrc.

Author

itchyny (https://github.com/itchyny)

License

MIT License

Installation

Manually

  1. Put all files under $VIM/.

Vundle (https://github.com/gmarik/vundle)

  1. Add the following configuration to your .vimrc.

     Bundle 'itchyny/lightline.vim'
    
  2. Install with :BundleInstall.

NeoBundle (https://github.com/Shougo/neobundle.vim)

  1. Add the following configuration to your .vimrc.

     NeoBundle 'itchyny/lightline.vim'
    
  2. Install with :NeoBundleInstall.

Configuration tutorial

In default, the statusline looks like: lightline.vim - tutorial If you want a wombat colorscheme, add the folowing settin to your .vimrc:

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ }

to get: lightline.vim - tutorial

If you have installed vim-fugitive, the branch status is automatically available: lightline.vim - tutorial but you find it annoying! So you add to your .vimrc:

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'readonly', 'filename', 'modified' ] ] }
        \ }

lightline.vim - tutorial OK. The branch section is removed.

However, you find the readonly mark is not cool: lightline.vim - tutorial So you add the component setting (the following setting is effective with the integrated font for vim-powerline):

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'readonly', 'filename', 'modified' ] ] },
        \ 'component': {
        \   'readonly': '%{&readonly?"⭤":""}'
        \ }
        \ }

lightline.vim - tutorial How nice!

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',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'readonly', 'filename', 'modified' ] ] },
        \ 'component': {
        \   'readonly': '%{&readonly?"⭤":""}'
        \ },
        \ 'separator': { 'left': '⮀', 'right': '⮂' },
        \ 'subseparator': { 'left': '⮁', 'right': '⮃' }
        \ }

lightline.vim - tutorial Hurrah! Cool!

Now, you look into a help file to find the marks annoying. Help files are readonly and no-modifiable? We know, of cource! lightline.vim - tutorial OK, so you again edit your .vimrc.

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'readonly', 'filename', 'modified' ] ] },
        \ 'component': {
        \   'readonly': '%{&filetype!="help"&& &readonly?"⭤":""}',
        \   'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
        \ },
        \ 'separator': { 'left': '⮀', 'right': '⮂' },
        \ 'subseparator': { 'left': '⮁', 'right': '⮃' }
        \ }

lightline.vim - tutorial Huh? Weird! The component does not collapse even if it has no information! In order to avoid this, you set expressions to component_flag, which becomes 1 only when the corresponding components have information.

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'readonly', 'filename', 'modified' ] ] },
        \ 'component': {
        \   'readonly': '%{&filetype!="help"&& &readonly?"⭤":""}',
        \   'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
        \ },
        \ 'component_flag': {
        \   'readonly': '(&filetype!="help"&& &readonly)',
        \   'modified': '(&filetype!="help"&&(&modified||!&modifiable))'
        \ },
        \ 'separator': { 'left': '⮀', 'right': '⮂' },
        \ 'subseparator': { 'left': '⮁', 'right': '⮃' }
        \ }

lightline.vim - tutorial Okey. Works nice.

However, you may wonder we cannot gather these settings? Or, if you want to do something more complicated?

In fact, the components can be created using functions.

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'readonly', 'filename', 'modified' ] ] },
        \ 'component_func': {
        \   '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

lightline.vim - tutorial Fine and readable!

Finally, you come up with concatenating the three components: lightline.vim - tutorial Now you may now what to do.

  let g:lightline = {
        \ 'colorscheme': 'wombat',
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'filename' ] ] },
        \ 'component_func': {
        \   'filename': 'MyFilename',
        \   '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! MyFilename()
    return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
         \ ('' != expand('%t') ? expand('%t') : '[No Name]') .
         \ ('' != MyModified() ? ' ' . MyModified() : '')
  endfunction

Define your own filename component. It has priority over the component lightline has. lightline.vim - tutorial Looks nice.

Of cource, you can name your component as you wish.

  let g:lightline = {
        \ 'active': {
        \   'left': [ [ 'mode', 'paste' ],
        \             [ 'my_filename' ] ] },
        \ 'component_func': {
        \   'my_filename': 'MyFilename', ...

This is the end of the tutorial. Good luck with your nice statusline.

Description
A light and configurable statusline/tabline plugin for Vim
Readme MIT 1.3 MiB
Languages
Vim Script 100%