Make the wordcount ext more flexible for the def. filetypes
This allows the user to further adjust the g:airline#extensions#wordcount#filetypes configuration variable even after Vim has started up.
This commit is contained in:
parent
5e2ef0cd83
commit
a0ea8db1fc
@ -3,12 +3,13 @@
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:filetypes = get(g:, 'airline#extensions#wordcount#filetypes', '\vhelp|markdown|rst|org|text|asciidoc|tex|mail')
|
||||
let s:format = get(g:, 'airline#extensions#wordcount#format', '%d words')
|
||||
let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')
|
||||
let g:airline#extensions#wordcount#filetypes = get(g:, 'airline#extensions#wordcount#filetypes',
|
||||
\ '\vhelp|markdown|rst|org|text|asciidoc|tex|mail')
|
||||
|
||||
function! s:update()
|
||||
if match(&ft, s:filetypes) > -1
|
||||
if match(&ft, get(g:, 'airline#extensions#wordcount#filetypes')) > -1
|
||||
let l:mode = mode()
|
||||
if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S'
|
||||
let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
|
||||
@ -27,7 +28,7 @@ function! s:update()
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#wordcount#apply(...)
|
||||
if &ft =~ s:filetypes
|
||||
if match(&ft, get(g:, 'airline#extensions#wordcount#filetypes')) > -1
|
||||
call airline#extensions#prepend_to_section('z', '%{get(b:, "airline_wordcount", "")}')
|
||||
endif
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user