nvim: plugin: statusline: Show read only or modified status

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-05-21 13:17:58 +05:30
parent fd5c5b15f5
commit 3b7326b6ed

View file

@ -19,9 +19,24 @@ function! GetCursorPosition()
\ : ''
endfunction
function! GetFileStatus()
if &buftype != ''
return ''
endif
let l:file = expand('%:p')
let l:status =
\ (&readonly || (filereadable(l:file) && !filewritable(l:file))
\ ? 'R'
\ : '')
\ . (&modified ? '+m' : '')
return len(l:status) > 0 ? ' ' . l:status : ''
endfunction
function! ActiveStatus() abort
let statusline=""
let statusline.="%1*\ %{winnr()}\ "
let statusline.="%4*\ %{GetFileStatus()}"
let statusline.="%2*\ %Y\ "
let statusline.="%3*%<%f"
let statusline.="%="
@ -32,6 +47,7 @@ endfunction
function! PassiveStatus() abort
let statusline=""
let statusline.="%5*\ %{winnr()}\ "
let statusline.="%8*\ %{GetFileStatus()}"
let statusline.="%6*\ %Y\ "
let statusline.="%7*%<%f"
let statusline.="%="