From a2e20bc3ca7f68403f916da2b2344718db92bdd0 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Tue, 1 Aug 2017 19:25:20 +0200 Subject: [PATCH] spell: Display spelling language fixes: #1521 --- autoload/airline/init.vim | 1 + autoload/airline/parts.vim | 12 +++++++++++- doc/airline.txt | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index d718a245..1c68429e 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -25,6 +25,7 @@ function! airline#init#bootstrap() call s:check_defined('g:airline_detect_paste', 1) call s:check_defined('g:airline_detect_crypt', 1) call s:check_defined('g:airline_detect_spell', 1) + call s:check_defined('g:airline_detect_spelllang', 1) call s:check_defined('g:airline_detect_iminsert', 0) call s:check_defined('g:airline_inactive_collapse', 1) call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus']) diff --git a/autoload/airline/parts.vim b/autoload/airline/parts.vim index f7b56fb8..a9820622 100644 --- a/autoload/airline/parts.vim +++ b/autoload/airline/parts.vim @@ -65,7 +65,17 @@ function! airline#parts#paste() endfunction function! airline#parts#spell() - return g:airline_detect_spell && &spell ? g:airline_symbols.spell : '' + let spelllang = g:airline_detect_spelllang ? printf(" [%s]", toupper(substitute(&spelllang, ',', '/', 'g'))) : '' + if g:airline_detect_spell && &spell + if winwidth(0) >= 90 + return g:airline_symbols.spell . spelllang + elseif winwidth(0) >= 70 + return g:airline_symbols.spell + else + return split(g:airline_symbols.spell, '\zs')[0] + endif + endif + return '' endfunction function! airline#parts#iminsert() diff --git a/doc/airline.txt b/doc/airline.txt index 86180185..32fd4a98 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -131,6 +131,10 @@ values): * enable spell detection > let g:airline_detect_spell=1 + +* display spelling language when spell detection is enabled + (if enough space is available) > + let g:airline_detect_spelllang=1 < * enable iminsert detection > let g:airline_detect_iminsert=0