From b2bbe7dbc272a0f4401dc7ec78f56737fd0523b0 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 24 Feb 2017 18:25:29 +0100 Subject: [PATCH] Small wordcount format output on windows < 80 --- .../wordcount/formatters/default.vim | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/autoload/airline/extensions/wordcount/formatters/default.vim b/autoload/airline/extensions/wordcount/formatters/default.vim index bb49c3f7..9acf0749 100644 --- a/autoload/airline/extensions/wordcount/formatters/default.vim +++ b/autoload/airline/extensions/wordcount/formatters/default.vim @@ -8,14 +8,20 @@ function! airline#extensions#wordcount#formatters#default#format() if empty(words) return endif - let separator = s:get_decimal_group() - if words > 999 && !empty(separator) - " Format number according to locale, e.g. German: 1.245 or English: 1,245 - let a = join(reverse(split(words, '.\zs')),'') - let a = substitute(a, '...', '&'.separator, 'g') - let words = join(reverse(split(a, '.\zs')),'') + 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() + if words > 999 && !empty(separator) + " Format number according to locale, e.g. German: 1.245 or English: 1,245 + 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 - return words . " words" . g:airline_symbols.space . g:airline_right_alt_sep . g:airline_symbols.space + return result endfunction function! s:wordcount()