Switch from vim-airline to lightline

Reason

vim-airline is an excellent vim plugin which gives you a fancy status line and makes the coding not that boring. However, recently I found it slowing down the vim start-up time.

I haven’t had this issue before, now it took at least 2 seconds to start the a vim session. I guess one reason may be the /home directory is NFS-mounted and recently more people are using it.

I suspect the vim-airline plugin because vim is freezing for 1s before airline status bar shows up. Then I disable the plugin, vim starts up in almost no time. It might be too heavy.

Switch to lightline

However, I really like the fancy status bar. After searching, I find a very nice alternative - lightline.

Installation

Installation is very simple if you have a plugin manager like vundle or vim-plug. (BTW, I am using vim-plug now.) Just comment out the old and add the new plugin.

1
2
3
4
5
" Comment the Old
" Plug 'vim-airline/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
" Add new plugin
Plug 'itchyny/lightline.vim'

Configuration

Actually the default setting is good enough. I just did some simple Configuration.

  • Change color scheme
  • Show git branch info (need vim-fugtive plugin)
  • Use powerline symbols
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let g:lightline = {
\ 'colorscheme': 'Dracula',
\ 'active': {
\ 'left':[ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ]
\ ]
\ },
\ 'component': {
\ 'lineinfo': ' %3l:%-2v',
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head',
\ }
\ }
let g:lightline.separator = {
\ 'left': '', 'right': ''
\}
let g:lightline.subseparator = {
\ 'left': '', 'right': ''
\}
  • Show tabline and disable the GUI tabline
1
2
3
4
5
6
let g:lightline.tabline = {
\ 'left': [ ['tabs'] ],
\ 'right': [ ['close'] ]
\ }
set showtabline=2 " Show tabline
set guioptions-=e " Don't use GUI tabline

Misc

I managed to show buffers on tabline, but it is too long when you open many files. Then I use vim-bufferline plugin instead.

Result

Final Result

Vim start-up time is very fast now and I still have a fancy status bar. I am happy with it ^_^.

Contents
  1. 1. Reason
  2. 2. Switch to lightline
    1. 2.1. Installation
    2. 2.2. Configuration
      1. 2.2.1. Misc
    3. 2.3. Result
|