diff --git a/autoload/airline.vim b/autoload/airline.vim index f19d2fbe..bd14a97f 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -175,6 +175,10 @@ function! airline#check_mode(winnr) call add(l:mode, 'crypt') endif + if g:airline_detect_spell && &spell + call add(l:mode, 'spell') + endif + if &readonly || ! &modifiable call add(l:mode, 'readonly') endif diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index 2a30f31a..dc7270b5 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -22,6 +22,7 @@ function! airline#init#bootstrap() call s:check_defined('g:airline_detect_modified', 1) 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_iminsert', 0) call s:check_defined('g:airline_inactive_collapse', 1) call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus']) @@ -58,6 +59,7 @@ function! airline#init#bootstrap() call s:check_defined('g:airline_symbols', {}) call extend(g:airline_symbols, { \ 'paste': 'PASTE', + \ 'spell': 'SPELL', \ 'readonly': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO', \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? "\u2739" : '!', \ 'linenr': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a1" : ':', @@ -75,6 +77,7 @@ function! airline#init#bootstrap() call airline#parts#define_function('iminsert', 'airline#parts#iminsert') call airline#parts#define_function('paste', 'airline#parts#paste') call airline#parts#define_function('crypt', 'airline#parts#crypt') + call airline#parts#define_function('spell', 'airline#parts#spell') call airline#parts#define_function('filetype', 'airline#parts#filetype') call airline#parts#define('readonly', { \ 'function': 'airline#parts#readonly', @@ -102,7 +105,7 @@ endfunction function! airline#init#sections() let spc = g:airline_symbols.space if !exists('g:airline_section_a') - let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'capslock', 'iminsert']) + let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'spell', 'capslock', 'iminsert']) endif if !exists('g:airline_section_b') let g:airline_section_b = airline#section#create(['hunks', 'branch']) diff --git a/autoload/airline/parts.vim b/autoload/airline/parts.vim index eab96242..0c1fd668 100644 --- a/autoload/airline/parts.vim +++ b/autoload/airline/parts.vim @@ -62,6 +62,10 @@ function! airline#parts#paste() return g:airline_detect_paste && &paste ? g:airline_symbols.paste : '' endfunction +function! airline#parts#spell() + return g:airline_detect_spell && &spell ? g:airline_symbols.spell : '' +endfunction + function! airline#parts#iminsert() if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name') return toupper(b:keymap_name) diff --git a/doc/airline.txt b/doc/airline.txt index 82956bbb..34478d7c 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -72,6 +72,9 @@ values): < * enable crypt detection > let g:airline_detect_crypt=1 + +* enable spell detection > + let g:airline_detect_spell=1 < * enable iminsert detection > let g:airline_detect_iminsert=0 @@ -191,6 +194,7 @@ its contents. > let g:airline_symbols.paste = 'ρ' let g:airline_symbols.paste = 'Þ' let g:airline_symbols.paste = '∥' + let g:airline_symbols.spell = 'Ꞩ' let g:airline_symbols.notexists = '∄' let g:airline_symbols.whitespace = 'Ξ' @@ -223,7 +227,7 @@ section. > variable names default contents ---------------------------------------------------------------------------- - let g:airline_section_a (mode, crypt, paste, iminsert) + let g:airline_section_a (mode, crypt, paste, spell, iminsert) let g:airline_section_b (hunks, branch) let g:airline_section_c (bufferline or filename) let g:airline_section_gutter (readonly, csv) @@ -771,6 +775,7 @@ Before is a list of parts that are predefined by vim-airline. * `iminsert` displays the current insert method * `paste` displays the paste indicator * `crypt` displays the crypted indicator +* `spell` displays the spell indicator * `filetype` displays the file type * `readonly` displays the read only indicator * `file` displays the filename and modified indicator diff --git a/t/init.vim b/t/init.vim index d1a2abb8..acb9f194 100644 --- a/t/init.vim +++ b/t/init.vim @@ -18,9 +18,10 @@ describe 'init sections' call s:clear() end - it 'section a should have mode, paste, iminsert' + it 'section a should have mode, paste, spell, iminsert' Expect g:airline_section_a =~ 'mode' Expect g:airline_section_a =~ 'paste' + Expect g:airline_section_a =~ 'spell' Expect g:airline_section_a =~ 'iminsert' end