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