parent
bb4be0095d
commit
e59c3ecd6e
@ -206,6 +206,10 @@ function! airline#extensions#load()
|
||||
call airline#extensions#whitespace#init(s:ext)
|
||||
endif
|
||||
|
||||
if get(g:, 'airline#extensions#wordcount#enabled', 1)
|
||||
call airline#extensions#wordcount#init(s:ext)
|
||||
endif
|
||||
|
||||
if get(g:, 'airline#extensions#tabline#enabled', 0)
|
||||
call airline#extensions#tabline#init(s:ext)
|
||||
endif
|
||||
|
32
autoload/airline/extensions/wordcount.vim
Normal file
32
autoload/airline/extensions/wordcount.vim
Normal file
@ -0,0 +1,32 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let g:airline#extensions#wordcount#filetypes = '\vhelp|markdown|rst|org'
|
||||
|
||||
" http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
|
||||
function! airline#extensions#wordcount#count()
|
||||
let old_status = v:statusmsg
|
||||
let position = getpos(".")
|
||||
exe "silent normal g\<c-g>"
|
||||
let cnt = 0
|
||||
let stat = v:statusmsg
|
||||
if stat != '--No lines in buffer--'
|
||||
let cnt = str2nr(split(v:statusmsg)[11])
|
||||
end
|
||||
call setpos('.', position)
|
||||
let v:statusmsg = old_status
|
||||
return cnt
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#wordcount#apply(...)
|
||||
if &ft =~ g:airline#extensions#wordcount#filetypes
|
||||
let spc = g:airline_symbols.space
|
||||
call airline#extensions#prepend_to_section('z',
|
||||
\ '%{airline#extensions#wordcount#count()}' . spc . 'words' . spc . g:airline_right_alt_sep .spc)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#wordcount#init(ext)
|
||||
call a:ext.add_statusline_func('airline#extensions#wordcount#apply')
|
||||
endfunction
|
||||
|
@ -401,6 +401,15 @@ eclim <https://eclim.org>
|
||||
|airline-syntastic| extension. >
|
||||
let g:airline#extensions#eclim#enabled = 1
|
||||
|
||||
------------------------------------- *airline-wordcount*
|
||||
* enable/disable word counting. >
|
||||
let g:airline#extensions#wordcount#enabled = 1
|
||||
<
|
||||
* regex of filetypes to enable word counting. >
|
||||
" the default value matches filetypes typically used for documentation
|
||||
" such as markdown and help files.
|
||||
let g:airline#extensions#wordcount#filetypes = ...
|
||||
<
|
||||
------------------------------------- *airline-whitespace*
|
||||
* enable/disable detection of whitespace errors. >
|
||||
let g:airline#extensions#whitespace#enabled = 1
|
||||
|
Loading…
Reference in New Issue
Block a user