function something():
fun! GitTracks(...)
let file = a:0 ? a:1 : expand('%')
let message = system('git ls-files -- ' . file)
let is_tracked = (message =~ '^fatal:') ? 0 : strlen(message)
if is_tracked
hi StatusLine guibg=blue
else
hi StatusLine guibg=black
endif
return is_tracked
endfun
'updatetime'
的设置。你可以从函数中删除它,并使用BufEnter
自动命令来检查GitTracks()
的值。):set stl+=%{GitTracks()?'tracked':'NOT\ tracked'}
set statusline=%f
set statusline+=%{fugitive#statusline()}
当然,你可以尽情发挥。http://learnvimscriptthehardway.stevelosh.com/chapters/17.html