-
Notifications
You must be signed in to change notification settings - Fork 11
Configuration Comparison
The main reason vim-crystalline exists is to provide a vanilla way to help you create your own statusline/tabline. This article shows you the difference between customizing vim-crystalline and other plugins.
Vim lets you set a statusline easily, but it's not very fancy:
set statusline=%f%h%w%m%r
You can use vim statusline components:
function! g:CrystallineStatuslineFn(winnr) abort
return ' %f%h%w%m%r '
endfunction
You can add components to the statusline without declaring them:
function! g:CrystallineStatuslineFn(winnr) abort
return ' %f%h%w%m%r ' . FugitiveHead()
endfunction
The statusline can be completely changed based on different conditions:
function! g:CrystallineStatuslineFn(winnr) abort
return ' %f%h%w%m%r ' . (winwidth(a:winnr) > 80 ? FugitiveHead() : '')
endfunction
Various functions help you make your statusline nicer:
function! g:CrystallineStatuslineFn(winnr) abort
return crystalline#HiItem('A')
\ . ' %f%h%w%m%r '
\ . crystalline#Sep(0, 'A', 'B')
\ . (winwidth(a:winnr) > 80 ? FugitiveHead() : '')
endfunction
More examples are available in the README.
See also :help crystalline
.
Sections must be declared as followed:
function! AirlineInit()
let g:airline_section_a = airline#section#create(['mode', ' ', 'head'])
let g:airline_section_y = airline#section#create_right(['ffenc','head'])
endfunction
autocmd User AirlineAfterInit call AirlineInit()
You are limited to the sections defined by vim-airline (a, b, c, x, y, z).
Functions can be declared as follows:
call airline#parts#define_function('head', 'FugitiveHead')
Minimum width and conditions can be defined as follows:
call airline#parts#define_minwidth('head', 50)
call airline#parts#define_condition('foo', 'getcwd() =~ "work_dir"')
Conditions are limited to changing individual components.
Functions have to be declared to be used:
let g:lightline = {
\ 'component_function': {
\ 'head': 'FugitiveHead'
\ },
\ 'active': {
\ 'left': [
\ ['mode'],
\ ['filename', 'modified', 'head']
\ ]
\ },
\ }
You are limited to the statusline structure lightline.vim has created.
Conditions are limited to changing individual components:
let g:lightline = {
\ 'component_function': {
\ 'head': 'LightlineHead',
\ 'fileformat': 'LightlineFileformat'
\ },
\ 'active': {
\ 'left': [
\ ['mode'],
\ ['filename', 'modified', 'fileformat', 'head']
\ ]
\ },
\ }
function! LightlineHead()
return winwidth(0) > 80 ? FugitiveHead() : ''
endfunction
function! LightlineFileformat()
return winwidth(0) > 80 ? &fileformat : ''
endfunction
A function has to be created for each individual custom component.
Other statusline plugins use similar configuration methods to vim-airline and lightline.vim. If you have examples you would like to contribute for other plugins, please post an issue.