allow wordcount filetypes to be customized. resolves #864.

This commit is contained in:
Bailey Ling 2015-10-07 20:44:34 -04:00
parent 2637e3ee58
commit 8c30610c5f

View File

@ -1,11 +1,11 @@
" MIT License. Copyright (c) 2013-2015 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let g:airline#extensions#wordcount#filetypes = '\vhelp|markdown|rst|org' let s:filetypes = get(g:, 'airline#extensions#wordcount#filetypes', '\vhelp|markdown|rst|org')
" adapted from http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim " adapted from http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
function! s:update() function! s:update()
if &ft !~ g:airline#extensions#wordcount#filetypes if &ft !~ s:filetypes
unlet! b:airline_wordcount unlet! b:airline_wordcount
return return
endif endif
@ -28,7 +28,7 @@ function! s:update()
endfunction endfunction
function! airline#extensions#wordcount#apply(...) function! airline#extensions#wordcount#apply(...)
if &ft =~ g:airline#extensions#wordcount#filetypes if &ft =~ s:filetypes
call airline#extensions#prepend_to_section('z', '%{get(b:, "airline_wordcount", "")}') call airline#extensions#prepend_to_section('z', '%{get(b:, "airline_wordcount", "")}')
endif endif
endfunction endfunction