2013-08-16 18:04:03 +00:00
|
|
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
2013-08-21 15:14:12 +00:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
2013-08-16 18:04:03 +00:00
|
|
|
|
|
|
|
" Extension specific variables can be defined the usual fashion.
|
|
|
|
if !exists('g:airline#extensions#example#number_of_cats')
|
|
|
|
let g:airline#extensions#example#number_of_cats = 42
|
|
|
|
endif
|
|
|
|
|
2013-08-25 15:39:11 +00:00
|
|
|
" There are predominantly two methods for integrating a plugin into
|
|
|
|
" vim-airline. The first method here simply modifies the global section and
|
|
|
|
" appends information to it. This is useful for cases where the information
|
|
|
|
" should be displayed all the time for all filetypes.
|
|
|
|
function! airline#extensions#example#init(ext)
|
|
|
|
let g:airline_section_y .= '%{airline#extensions#example#get_cats()}'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" The second method involves using the 'ext'ension manager that was passed in
|
|
|
|
" and appends a name of a function. This function will be invoked just prior
|
|
|
|
" to updating the statusline. This method is useful for plugin-specific
|
|
|
|
" statuslines (like NERDTree or Tagbar) or language specific plugins (like
|
|
|
|
" virtualenv) which do not need to be loaded all the time.
|
2013-08-16 18:04:03 +00:00
|
|
|
function! airline#extensions#example#init(ext)
|
2013-08-23 21:22:20 +00:00
|
|
|
call a:ext.add_statusline_func('airline#extensions#example#apply')
|
2013-08-16 18:04:03 +00:00
|
|
|
|
2013-08-25 15:39:11 +00:00
|
|
|
" There is also the following function for making changes just prior to an
|
|
|
|
" inactive statusline.
|
|
|
|
" call a:ext.add_inactive_statusline_func('airline#extensions#example#unapply')
|
2013-08-16 18:04:03 +00:00
|
|
|
endfunction
|
|
|
|
|
2013-08-25 15:39:11 +00:00
|
|
|
" This function will be invoked just prior to the statusline getting modified.
|
2013-08-21 15:14:12 +00:00
|
|
|
function! airline#extensions#example#apply(...)
|
2013-08-25 15:39:11 +00:00
|
|
|
" First we check for the filetype.
|
2013-08-16 18:04:03 +00:00
|
|
|
if &filetype == "nyancat"
|
2013-08-25 15:39:11 +00:00
|
|
|
" Let's use a helper function. It will take care of ensuring that the
|
|
|
|
" window-local override exists (and create one based on the global
|
|
|
|
" airline_section if not), and prepend to it.
|
|
|
|
call airline#extensions#prepend_to_section('x', '%{airline#extensions#example#get_cats()} ')
|
2013-08-16 18:04:03 +00:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Finally, this function will be invoked from the statusline.
|
|
|
|
function! airline#extensions#example#get_cats()
|
|
|
|
let cats = ''
|
|
|
|
for i in range(1, g:airline#extensions#example#number_of_cats)
|
|
|
|
let cats .= ' (,,,)=(^.^)=(,,,) '
|
|
|
|
endfor
|
|
|
|
return cats
|
|
|
|
endfunction
|
|
|
|
|