diff --git a/common/magit_common.vim b/common/magit_common.vim index 7232aa73b3e46cbc0a1e1ace10e5eb10372c1e33..718bb4542a60e83ee035c3f894348125bc9356e1 100644 --- a/common/magit_common.vim +++ b/common/magit_common.vim @@ -14,6 +14,7 @@ let g:magit_section_info = { \ 'cur_repo': 'Current repository', \ 'cur_branch': 'Current branch', \ 'cur_commit': 'Last commit', + \ 'commit_mode': 'Commit mode', \ } let g:magit_git_status_code = { @@ -31,6 +32,11 @@ let g:magit_git_status_code = { \ 'S': 'submodule', \ } +let g:magit_commit_mode = { + \ 'CC': 'normal', + \ 'CA': 'amend', + \ } + " Regular expressions used to select blocks let g:magit_file_re = '^\(' for status_code in values(g:magit_git_status_code) diff --git a/plugin/magit.vim b/plugin/magit.vim index 9c2697bbd4ccfd840b448d7dc68b5c59be574e63..540ca16146f91e8b9f292a2cb20e749c5a950d9e 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -121,9 +121,13 @@ function! s:mg_get_info() silent put ='' let branch=magit#utils#system("git rev-parse --abbrev-ref HEAD") let commit=magit#utils#system("git show -s --oneline") - silent put =g:magit_section_info.cur_repo . ': ' . magit#git#top_dir() - silent put =g:magit_section_info.cur_branch . ': ' . branch - silent put =g:magit_section_info.cur_commit . ': ' . commit + silent put =g:magit_section_info.cur_repo . ': ' . magit#git#top_dir() + silent put =g:magit_section_info.cur_branch . ': ' . branch + silent put =g:magit_section_info.cur_commit . ': ' . commit + if ( s:magit_commit_mode != '' ) + silent put =g:magit_section_info.commit_mode . ': ' + \ . g:magit_commit_mode[s:magit_commit_mode] + endif silent put ='' silent put ='Press h to display help' endfunction @@ -226,15 +230,8 @@ let s:magit_commit_mode='' " 'CA': get the last commit message function! s:mg_get_commit_section() if ( s:magit_commit_mode != '' ) - let commit_mode_str="" - if ( s:magit_commit_mode == 'CC' ) - let commit_mode_str="normal" - elseif ( s:magit_commit_mode == 'CA' ) - let commit_mode_str="amend" - endif silent put ='' silent put =g:magit_sections.commit_start - silent put ='Commit mode: '.commit_mode_str call <SID>mg_section_help('commit') silent put =magit#utils#underline(g:magit_sections.commit_start) silent put ='' @@ -324,7 +321,7 @@ function! s:mg_git_commit(mode) abort else let commit_section_pat_start='^'.g:magit_sections.commit_start.'$' let commit_section_pat_end='^'.g:magit_sections.commit_end.'$' - let commit_jump_line = 3 + <SID>mg_get_inline_help_line_nb('commit') + let commit_jump_line = 2 + <SID>mg_get_inline_help_line_nb('commit') let [start, end] = <SID>mg_search_block( \ [commit_section_pat_start, commit_jump_line], \ [ [commit_section_pat_end, -1] ], "") @@ -557,7 +554,7 @@ function! magit#update_buffer() if ( s:magit_commit_mode != '' ) let commit_section_pat_start='^'.g:magit_sections.commit_start.'$' silent! let section_line=search(commit_section_pat_start, "w") - silent! call cursor(section_line+3+<SID>mg_get_inline_help_line_nb('commit'), 0) + silent! call cursor(section_line+2+<SID>mg_get_inline_help_line_nb('commit'), 0) endif set filetype=magit diff --git a/syntax/magit.vim b/syntax/magit.vim index 8e6b0be1cb5ecbb17fbc26d07a235f1f1a562150..904d8d373938c7d4f252750028d2151d80eaa34c 100644 --- a/syntax/magit.vim +++ b/syntax/magit.vim @@ -39,6 +39,9 @@ highlight default link gitInfoRepo Directory execute 'syn region gitInfoBranch start=/^' . g:magit_section_info.cur_branch . \ ':\s*.*/hs=s+20 end=/$/ oneline' highlight default link gitInfoBranch Identifier +execute 'syn region gitCommitMode start=/^' . g:magit_section_info.commit_mode . + \ ':\s*.*/hs=s+20 end=/$/ oneline' +highlight default link gitCommitMode Special execute 'syn region gitInfoCommit start=/^' . g:magit_section_info.cur_commit . \ ':\s*\(.*\)/ end=/$/ contains=infoSha1 oneline'