Small wordcount format output on windows < 80

This commit is contained in:
Christian Brabandt 2017-02-24 18:25:29 +01:00
parent 562d060b08
commit b2bbe7dbc2
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
1 changed files with 13 additions and 7 deletions

View File

@ -8,14 +8,20 @@ function! airline#extensions#wordcount#formatters#default#format()
if empty(words) if empty(words)
return return
endif endif
let separator = s:get_decimal_group() let result = g:airline_symbols.space . g:airline_right_alt_sep . g:airline_symbols.space
if words > 999 && !empty(separator) if winwidth(0) >= 80
" Format number according to locale, e.g. German: 1.245 or English: 1,245 let separator = s:get_decimal_group()
let a = join(reverse(split(words, '.\zs')),'') if words > 999 && !empty(separator)
let a = substitute(a, '...', '&'.separator, 'g') " Format number according to locale, e.g. German: 1.245 or English: 1,245
let words = join(reverse(split(a, '.\zs')),'') let a = join(reverse(split(words, '.\zs')),'')
let a = substitute(a, '...', '&'.separator, 'g')
let words = join(reverse(split(a, '.\zs')),'')
endif
let result = printf("%s%s", words, " words"). result
else
let result = printf("%s%s", words, "W"). result
endif endif
return words . " words" . g:airline_symbols.space . g:airline_right_alt_sep . g:airline_symbols.space return result
endfunction endfunction
function! s:wordcount() function! s:wordcount()