2018-01-05 04:37:59 -05:00
|
|
|
" MIT License. Copyright (c) 2013-2018 Bailey Ling et al.
|
2016-01-25 15:00:05 -05:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2016-09-23 20:16:30 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2018-06-30 13:34:12 -04:00
|
|
|
let s:fmt = get(g:, 'airline#extensions#wordcount#formatter#default#fmt', '%s words')
|
|
|
|
let s:fmt_short = get(g:, 'airline#extensions#wordcount#formatter#default#fmt_short', s:fmt == '%s words' ? '%sW' : s:fmt)
|
|
|
|
|
|
|
|
function! airline#extensions#wordcount#formatters#default#transform(text)
|
|
|
|
if empty(a:text)
|
2016-01-25 15:00:05 -05:00
|
|
|
return
|
|
|
|
endif
|
2018-06-30 13:34:12 -04:00
|
|
|
|
2017-02-24 12:25:29 -05:00
|
|
|
let result = g:airline_symbols.space . g:airline_right_alt_sep . g:airline_symbols.space
|
|
|
|
if winwidth(0) >= 80
|
|
|
|
let separator = s:get_decimal_group()
|
2018-06-30 13:34:12 -04:00
|
|
|
if a:text > 999 && !empty(separator)
|
2017-02-24 12:25:29 -05:00
|
|
|
" Format number according to locale, e.g. German: 1.245 or English: 1,245
|
2018-06-30 13:34:12 -04:00
|
|
|
let text = substitute(a:text, '\d\@<=\(\(\d\{3\}\)\+\)$', separator.'&', 'g')
|
2016-02-08 16:58:07 -05:00
|
|
|
else
|
2018-06-30 13:34:12 -04:00
|
|
|
let text = a:text
|
2016-02-08 16:58:07 -05:00
|
|
|
endif
|
2018-06-30 13:34:12 -04:00
|
|
|
let result = printf(s:fmt, a:text). result
|
2016-01-25 15:00:05 -05:00
|
|
|
else
|
2018-06-30 13:34:12 -04:00
|
|
|
let result = printf(s:fmt_short, a:text). result
|
2016-01-25 15:00:05 -05:00
|
|
|
endif
|
2018-06-30 13:34:12 -04:00
|
|
|
return result
|
2016-01-25 15:00:05 -05:00
|
|
|
endfunction
|
|
|
|
|
2016-04-20 15:10:28 -04:00
|
|
|
function! s:get_decimal_group()
|
2018-06-04 15:45:46 -04:00
|
|
|
if match(get(v:, 'lang', ''), '\v\cC|en') > -1
|
2016-01-25 15:00:05 -05:00
|
|
|
return ','
|
2018-06-04 15:45:46 -04:00
|
|
|
elseif match(get(v:, 'lang', ''), '\v\cde|dk|fr|pt') > -1
|
2016-01-25 15:00:05 -05:00
|
|
|
return '.'
|
|
|
|
endif
|
|
|
|
return ''
|
|
|
|
endfunction
|
2018-06-30 13:34:12 -04:00
|
|
|
|