Added visual mode word counting
This commit is contained in:
parent
fb5ecd4703
commit
447cf71ef2
@ -7,13 +7,19 @@ let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')
|
||||
|
||||
function! s:update()
|
||||
if match(&ft, s:filetypes) > -1
|
||||
if get(b:, 'airline_wordcount_cache', '') is# '' ||
|
||||
\ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') ||
|
||||
\ get(b:, 'airline_change_tick', 0) != b:changedtick
|
||||
" cache data
|
||||
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()
|
||||
let b:airline_wordcount_cache = b:airline_wordcount
|
||||
let b:airline_change_tick = b:changedtick
|
||||
else
|
||||
if get(b:, 'airline_wordcount_cache', '') is# '' ||
|
||||
\ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') ||
|
||||
\ get(b:, 'airline_change_tick', 0) != b:changedtick
|
||||
" cache data
|
||||
let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
|
||||
let b:airline_wordcount_cache = b:airline_wordcount
|
||||
let b:airline_change_tick = b:changedtick
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
@ -18,7 +18,17 @@ endfunction
|
||||
|
||||
function! s:wordcount()
|
||||
if exists("*wordcount")
|
||||
return wordcount()['words']
|
||||
let l:mode = mode()
|
||||
if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S'
|
||||
let l:visual_words = wordcount()['visual_words']
|
||||
if l:visual_words != ''
|
||||
return l:visual_words
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
else
|
||||
return wordcount()['words']
|
||||
endif
|
||||
elseif mode() =~? 's'
|
||||
return
|
||||
else
|
||||
@ -41,7 +51,7 @@ endfunction
|
||||
function s:get_decimal_group()
|
||||
if match(v:lang, '\v\cC|en') > -1
|
||||
return ','
|
||||
elseif match(v:lang, '\v\cde|dk|fr') > -1
|
||||
elseif match(v:lang, '\v\cde|dk|fr|pt') > -1
|
||||
return '.'
|
||||
endif
|
||||
return ''
|
||||
|
Loading…
Reference in New Issue
Block a user