2021-01-01 20:57:00 +08:00
|
|
|
" MIT License. Copyright (c) 2016-2021 Jerome Reybert et al.
|
2019-11-09 03:18:04 +08:00
|
|
|
" Plugin: https://github.com/jreybert/vimagit
|
2017-01-19 20:57:36 +08:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2019-03-25 19:27:10 +08:00
|
|
|
" This plugin replaces the whole section_a when in vimagit buffer
|
2017-01-19 20:57:36 +08:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
|
|
|
if !get(g:, 'loaded_magit', 0)
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2020-09-03 17:51:23 +08:00
|
|
|
let s:commit_mode = {'ST': 'STAGING', 'CC': 'COMMIT', 'CA': 'AMEND'}
|
2020-05-21 14:19:25 +08:00
|
|
|
|
2020-05-21 00:26:33 +08:00
|
|
|
function! airline#extensions#vimagit#init(ext) abort
|
2017-01-19 20:57:36 +08:00
|
|
|
call a:ext.add_statusline_func('airline#extensions#vimagit#apply')
|
|
|
|
endfunction
|
|
|
|
|
2020-05-21 00:26:33 +08:00
|
|
|
function! airline#extensions#vimagit#get_mode() abort
|
2017-11-20 20:47:48 +08:00
|
|
|
if ( exists("*magit#get_current_mode") )
|
|
|
|
return magit#get_current_mode()
|
|
|
|
else
|
2020-05-21 14:19:25 +08:00
|
|
|
return get(s:commit_mode, b:magit_current_commit_mode, '???')
|
2020-05-21 00:26:33 +08:00
|
|
|
endif
|
2017-01-19 20:57:36 +08:00
|
|
|
endfunction
|
|
|
|
|
2020-05-21 00:26:33 +08:00
|
|
|
function! airline#extensions#vimagit#apply(...) abort
|
2017-01-19 20:57:36 +08:00
|
|
|
if ( &filetype == 'magit' )
|
|
|
|
let w:airline_section_a = '%{airline#extensions#vimagit#get_mode()}'
|
|
|
|
endif
|
|
|
|
endfunction
|