I use neovim and I made my own statusline, which used to work perfectly. It showed the status of the file (saved/modified etc) and the mode, in text as well as in color. The color got updated immediately (so when when a file got modified, and u was pressed, the file part of the statusline turned green again and it said "saved"). Since a recent update, this does not work anymore. The text still changes, but the color only updates after pressing another key.
Here is my code:
" Status and command line
function! GetModify()
if &readonly || !&modifiable
highlight User5 ctermfg=1 ctermbg=none cterm=bold
highlight User6 ctermfg=0 ctermbg=1 cterm=bold
redraw
return '(Readonly)'
elseif &modified
highlight User5 ctermfg=9 ctermbg=none cterm=bold
highlight User6 ctermfg=0 ctermbg=9 cterm=bold
redraw
return '(Modefied)'
elseif empty(glob(expand('%:p')))
highlight User5 ctermfg=12 ctermbg=none cterm=bold
highlight User6 ctermfg=0 ctermbg=12 cterm=bold
redraw
return '(New) '
else
highlight User5 ctermfg=10 ctermbg=none cterm=bold
highlight User6 ctermfg=0 ctermbg=10 cterm=bold
redraw
return '(Saved) '
endif
endfunction
function! GetMode()
let mode=mode()
if mode=='n'
highlight User2 ctermfg=0 ctermbg=11 cterm=bold
highlight User3 ctermfg=11 cterm=bold
redraw
return 'Normal '
elseif mode=='i'
highlight User2 ctermfg=0 ctermbg=2 cterm=bold
highlight User3 ctermfg=2 cterm=bold
redraw
return 'Insert '
elseif mode=='c'
highlight User2 ctermfg=0 ctermbg=14 cterm=bold
highlight User3 ctermfg=14 cterm=bold
redraw
return 'Command'
elseif mode=='v'||mode==''
highlight User2 ctermfg=0 ctermbg=12 cterm=bold
highlight User3 ctermfg=12 cterm=bold
redraw
return 'Visual '
elseif mode=='R'
highlight User2 ctermfg=0 ctermbg=1 cterm=bold
highlight User3 ctermfg=1 cterm=bold
redraw
return 'Replace'
else
return mode
endif
endfunction
function! GetRecording()
highlight statusline ctermfg=15 ctermbg=0
highlight User1 ctermfg=7 ctermbg=5 cterm=bold
highlight User4 ctermfg=15
redraw
if reg_recording()!=''
return ' Recording @'.reg_recording().' '
else
return ''
endif
endfunction
function! GetPath()
let length=winwidth('%')-44-3
if reg_recording()!=''
let length-=14
endif
let path=substitute(expand('%:p'),'^'.expand('~'),'~','')
if len(path)>length
return '...'.path[-length:]
else
return path
endif
endfunction
set statusline=
set statusline+=%1*%{GetRecording()}
set statusline+=%2*\ %{GetMode()}\ %3*
set statusline+=%4*%4(%c%),%3(%l%)/%L\ [%4(%p%)%%]
set statusline+=%=
set statusline+=\ %5*%6*\ %{GetPath()}
set statusline+=\ %{GetModify()}
set laststatus=2
set showcmd
set noshowmode
The code is not very nice or exhaustive, but it used to work. I tested it with an empty init.vim file (only a reference to this file), but that had the same problem.
Thanks for your help!