Merge pull request #2205 from eevan78/master

Several fixes and improvements
This commit is contained in:
Christian Brabandt 2020-08-20 09:33:53 +02:00 committed by GitHub
commit 02c529efe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 10 deletions

View File

@ -153,9 +153,12 @@ if v:version >= 800 && has("job")
endfunction endfunction
function! airline#async#get_msgfmt_stat(cmd, file) function! airline#async#get_msgfmt_stat(cmd, file)
if g:airline#init#is_windows || !executable('msgfmt') if !executable('msgfmt')
" no msgfmt on windows? " no msgfmt
return return
endif
if g:airline#init#is_windows
let cmd = 'cmd /C ' . a:cmd. shellescape(a:file)
else else
let cmd = ['sh', '-c', a:cmd. shellescape(a:file)] let cmd = ['sh', '-c', a:cmd. shellescape(a:file)]
endif endif

View File

@ -9,7 +9,7 @@ endif
function! airline#extensions#keymap#status() function! airline#extensions#keymap#status()
if (get(g:, 'airline#extensions#keymap#enabled', 1) && has('keymap')) if (get(g:, 'airline#extensions#keymap#enabled', 1) && has('keymap'))
return printf('%s', (!empty(&keymap) ? (g:airline_symbols.keymap . ' '. &keymap) : '')) return printf('%s', (!empty(&keymap) && &iminsert ? (g:airline_symbols.keymap . ' '. &keymap) : ''))
else else
return '' return ''
endif endif

View File

@ -10,7 +10,7 @@ function! airline#extensions#po#shorten()
if exists("g:airline#extensions#po#displayed_limit") if exists("g:airline#extensions#po#displayed_limit")
let w:displayed_po_limit = g:airline#extensions#po#displayed_limit let w:displayed_po_limit = g:airline#extensions#po#displayed_limit
if len(b:airline_po_stats) > w:displayed_po_limit - 1 if len(b:airline_po_stats) > w:displayed_po_limit - 1
let b:airline_po_stats = b:airline_po_stats[0:(w:displayed_po_limit - 2)].(&encoding==?'utf-8' ? '…' : '.'). ']' let b:airline_po_stats = b:airline_po_stats[0:(w:displayed_po_limit - 2)].(&encoding==?'utf-8' ? '…' : '.')
endif endif
endif endif
if strlen(get(b:, 'airline_po_stats', '')) >= 30 && airline#util#winwidth() < 150 if strlen(get(b:, 'airline_po_stats', '')) >= 30 && airline#util#winwidth() < 150
@ -19,24 +19,27 @@ function! airline#extensions#po#shorten()
let messages = '' let messages = ''
" Shorten [120 translated, 50 fuzzy, 4 untranslated] to [120T/50F/4U] " Shorten [120 translated, 50 fuzzy, 4 untranslated] to [120T/50F/4U]
if b:airline_po_stats =~ 'fuzzy' if b:airline_po_stats =~ 'fuzzy'
let fuzzy = substitute(b:airline_po_stats, '.*\(\d\+\) fuzzy.*', '\1F', '') let fuzzy = substitute(b:airline_po_stats, '.\{-}\(\d\+\) fuzzy.*', '\1F', '')
if fuzzy == '0F' if fuzzy == '0F'
let fuzzy = '' let fuzzy = ''
endif endif
endif endif
if b:airline_po_stats =~ 'untranslated' if b:airline_po_stats =~ 'untranslated'
let untranslated = substitute(b:airline_po_stats, '.*\(\d\+\) untranslated.*', '\1U', '') let untranslated = substitute(b:airline_po_stats, '.\{-}\(\d\+\) untranslated.*', '\1U', '')
if untranslated == '0U' if untranslated == '0U'
let untranslated = '' let untranslated = ''
endif endif
endif endif
let messages = substitute(b:airline_po_stats, '\(\d\+\) translated.*', '\1T', '') let messages = substitute(b:airline_po_stats, '\(\d\+\) translated.*', '\1T', '')
if messages ==# '0T'
let messages = ''
endif
let b:airline_po_stats = printf('%s%s%s', fuzzy, (empty(fuzzy) || empty(untranslated) ? '' : '/'), untranslated) let b:airline_po_stats = printf('%s%s%s', fuzzy, (empty(fuzzy) || empty(untranslated) ? '' : '/'), untranslated)
if strlen(b:airline_po_stats) < 8 if strlen(b:airline_po_stats) < 10
let b:airline_po_stats = messages. (!empty(b:airline_po_stats) ? '/':''). b:airline_po_stats let b:airline_po_stats = messages. (!empty(b:airline_po_stats) && !empty(messages) ? '/':''). b:airline_po_stats
endif endif
endif endif
let b:airline_po_stats = '['.b:airline_po_stats. ']' let b:airline_po_stats = '['.b:airline_po_stats. '] '
endfunction endfunction
function! airline#extensions#po#on_winenter() function! airline#extensions#po#on_winenter()
@ -62,7 +65,11 @@ function! airline#extensions#po#stats()
return b:airline_po_stats return b:airline_po_stats
endif endif
if g:airline#init#is_windows
let cmd = 'msgfmt --statistics -o NUL '
else
let cmd = 'msgfmt --statistics -o /dev/null -- ' let cmd = 'msgfmt --statistics -o /dev/null -- '
endif
if g:airline#init#vim_async if g:airline#init#vim_async
call airline#async#get_msgfmt_stat(cmd, expand('%:p')) call airline#async#get_msgfmt_stat(cmd, expand('%:p'))
elseif has("nvim") elseif has("nvim")