mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 13:53:51 -05:00
Adjust section headers
This commit is contained in:
@@ -115,8 +115,32 @@ function! s:executable(binary) abort
|
|||||||
return s:executables[a:binary]
|
return s:executables[a:binary]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:UserCommand() abort
|
function! s:map(mode, lhs, rhs, ...) abort
|
||||||
return get(g:, 'fugitive_git_command', g:fugitive_git_executable)
|
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
||||||
|
let head = a:lhs
|
||||||
|
let tail = ''
|
||||||
|
let keys = get(g:, a:mode.'remap', {})
|
||||||
|
if type(keys) == type([])
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
while !empty(head)
|
||||||
|
if has_key(keys, head)
|
||||||
|
let head = keys[head]
|
||||||
|
if empty(head)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
||||||
|
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
||||||
|
endwhile
|
||||||
|
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
|
||||||
|
exe a:mode.'map <buffer>' flags head.tail a:rhs
|
||||||
|
if a:0 > 1
|
||||||
|
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
|
||||||
|
\ '|sil! exe "' . a:mode . 'unmap <buffer> ' . head.tail . '"'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:System(cmd) abort
|
function! s:System(cmd) abort
|
||||||
@@ -130,6 +154,12 @@ function! s:System(cmd) abort
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Section: Git
|
||||||
|
|
||||||
|
function! s:UserCommand() abort
|
||||||
|
return get(g:, 'fugitive_git_command', g:fugitive_git_executable)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:Prepare(dir, ...) abort
|
function! s:Prepare(dir, ...) abort
|
||||||
if type(a:dir) == type([])
|
if type(a:dir) == type([])
|
||||||
let args = ['--git-dir=' . (a:0 ? a:1 : get(b:, 'git_dir', ''))] + a:dir
|
let args = ['--git-dir=' . (a:0 ? a:1 : get(b:, 'git_dir', ''))] + a:dir
|
||||||
@@ -259,33 +289,7 @@ function! fugitive#RemoteUrl(...) abort
|
|||||||
return v:shell_error ? '' : out
|
return v:shell_error ? '' : out
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:map(mode, lhs, rhs, ...) abort
|
" Section: Repository Object
|
||||||
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
|
||||||
let head = a:lhs
|
|
||||||
let tail = ''
|
|
||||||
let keys = get(g:, a:mode.'remap', {})
|
|
||||||
if type(keys) == type([])
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
while !empty(head)
|
|
||||||
if has_key(keys, head)
|
|
||||||
let head = keys[head]
|
|
||||||
if empty(head)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
|
||||||
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
|
||||||
endwhile
|
|
||||||
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
|
|
||||||
exe a:mode.'map <buffer>' flags head.tail a:rhs
|
|
||||||
if a:0 > 1
|
|
||||||
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .
|
|
||||||
\ '|sil! exe "' . a:mode . 'unmap <buffer> ' . head.tail . '"'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:add_methods(namespace, method_names) abort
|
function! s:add_methods(namespace, method_names) abort
|
||||||
for name in a:method_names
|
for name in a:method_names
|
||||||
@@ -304,10 +308,6 @@ function! s:define_commands() abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:abstract_prototype = {}
|
|
||||||
|
|
||||||
" Section: Repository
|
|
||||||
|
|
||||||
let s:repo_prototype = {}
|
let s:repo_prototype = {}
|
||||||
let s:repos = {}
|
let s:repos = {}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ function! fugitive#repo(...) abort
|
|||||||
let repo = {'git_dir': dir}
|
let repo = {'git_dir': dir}
|
||||||
let s:repos[dir] = repo
|
let s:repos[dir] = repo
|
||||||
endif
|
endif
|
||||||
return extend(extend(repo, s:repo_prototype, 'keep'), s:abstract_prototype, 'keep')
|
return extend(repo, s:repo_prototype, 'keep')
|
||||||
endif
|
endif
|
||||||
call s:throw('not a git repository: '.expand('%:p'))
|
call s:throw('not a git repository: '.expand('%:p'))
|
||||||
endfunction
|
endfunction
|
||||||
@@ -404,7 +404,7 @@ endfunction
|
|||||||
|
|
||||||
call s:add_methods('repo',['config', 'user'])
|
call s:add_methods('repo',['config', 'user'])
|
||||||
|
|
||||||
" Section: Buffer
|
" Section: File API
|
||||||
|
|
||||||
function! s:DirCommitFile(path) abort
|
function! s:DirCommitFile(path) abort
|
||||||
let vals = matchlist(s:Slash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
let vals = matchlist(s:Slash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
||||||
@@ -483,6 +483,10 @@ function! fugitive#Path(url, ...) abort
|
|||||||
return substitute(file, '^/', a:1, '')
|
return substitute(file, '^/', a:1, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:Relative(...) abort
|
||||||
|
return fugitive#Path(@%, a:0 ? a:1 : './')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! fugitive#Route(object, ...) abort
|
function! fugitive#Route(object, ...) abort
|
||||||
if a:object =~# '^[~$]'
|
if a:object =~# '^[~$]'
|
||||||
let prefix = matchstr(a:object, '^[~$]\i*')
|
let prefix = matchstr(a:object, '^[~$]\i*')
|
||||||
@@ -903,11 +907,13 @@ function! fugitive#delete(url, ...) abort
|
|||||||
return v:shell_error ? -1 : 0
|
return v:shell_error ? -1 : 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Section: Buffer Object
|
||||||
|
|
||||||
let s:buffer_prototype = {}
|
let s:buffer_prototype = {}
|
||||||
|
|
||||||
function! fugitive#buffer(...) abort
|
function! fugitive#buffer(...) abort
|
||||||
let buffer = {'#': bufnr(a:0 ? a:1 : '%')}
|
let buffer = {'#': bufnr(a:0 ? a:1 : '%')}
|
||||||
call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep')
|
call extend(buffer, s:buffer_prototype, 'keep')
|
||||||
if buffer.getvar('git_dir') !=# ''
|
if buffer.getvar('git_dir') !=# ''
|
||||||
return buffer
|
return buffer
|
||||||
endif
|
endif
|
||||||
@@ -994,10 +1000,6 @@ function! s:buffer_relative(...) dict abort
|
|||||||
return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '')
|
return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Relative(...) abort
|
|
||||||
return fugitive#Path(@%, a:0 ? a:1 : './')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:buffer_path(...) dict abort
|
function! s:buffer_path(...) dict abort
|
||||||
if a:0
|
if a:0
|
||||||
return self.relative(a:1)
|
return self.relative(a:1)
|
||||||
@@ -1091,7 +1093,7 @@ function! fugitive#Complete(base, ...) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: File access
|
" Section: Buffer auto-commands
|
||||||
|
|
||||||
function! s:ReplaceCmd(cmd) abort
|
function! s:ReplaceCmd(cmd) abort
|
||||||
let tmp = tempname()
|
let tmp = tempname()
|
||||||
@@ -1430,7 +1432,7 @@ augroup fugitive_temp
|
|||||||
autocmd BufNewFile,BufReadPost * exe s:SetupTemp(expand('<amatch>:p'))
|
autocmd BufNewFile,BufReadPost * exe s:SetupTemp(expand('<amatch>:p'))
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Section: Git
|
" Section: :Git
|
||||||
|
|
||||||
call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(<bang>0,'<mods>',<q-args>)")
|
call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(<bang>0,'<mods>',<q-args>)")
|
||||||
|
|
||||||
@@ -1500,7 +1502,7 @@ function! s:GitComplete(A, L, P) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gcd, Glcd
|
" Section: :Gcd, :Glcd
|
||||||
|
|
||||||
function! s:DirComplete(A, L, P) abort
|
function! s:DirComplete(A, L, P) abort
|
||||||
return filter(fugitive#PathComplete(a:A), 'v:val =~# "/$"')
|
return filter(fugitive#PathComplete(a:A), 'v:val =~# "/$"')
|
||||||
@@ -1518,7 +1520,7 @@ endfunction
|
|||||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe 'cd<bang>' s:fnameescape(s:DirArg(<q-args>))")
|
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe 'cd<bang>' s:fnameescape(s:DirArg(<q-args>))")
|
||||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe 'lcd<bang>' s:fnameescape(s:DirArg(<q-args>))")
|
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe 'lcd<bang>' s:fnameescape(s:DirArg(<q-args>))")
|
||||||
|
|
||||||
" Section: Gstatus
|
" Section: :Gstatus
|
||||||
|
|
||||||
call s:command("-bar -bang -range=-1 Gstatus :execute s:Status(<bang>0, <count>, '<mods>')")
|
call s:command("-bar -bang -range=-1 Gstatus :execute s:Status(<bang>0, <count>, '<mods>')")
|
||||||
augroup fugitive_status
|
augroup fugitive_status
|
||||||
@@ -1811,7 +1813,7 @@ function! s:StagePatch(lnum1,lnum2) abort
|
|||||||
return 'checktime'
|
return 'checktime'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gcommit
|
" Section: :Gcommit
|
||||||
|
|
||||||
call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit('<mods>', <q-args>)")
|
call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit('<mods>', <q-args>)")
|
||||||
|
|
||||||
@@ -1932,7 +1934,7 @@ function! s:FinishCommit() abort
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gmerge, Gpull
|
" Section: :Gmerge, :Grebase, :Gpull
|
||||||
|
|
||||||
call s:command("-nargs=? -bang -complete=custom,s:RevisionComplete Gmerge " .
|
call s:command("-nargs=? -bang -complete=custom,s:RevisionComplete Gmerge " .
|
||||||
\ "execute s:Merge('merge', <bang>0, <q-args>)")
|
\ "execute s:Merge('merge', <bang>0, <q-args>)")
|
||||||
@@ -2058,7 +2060,7 @@ function! s:Merge(cmd, bang, args) abort
|
|||||||
return exists('err') ? 'echoerr '.string(err) : ''
|
return exists('err') ? 'echoerr '.string(err) : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Ggrep, Glog
|
" Section: :Ggrep, :Glog
|
||||||
|
|
||||||
if !exists('g:fugitive_summary_format')
|
if !exists('g:fugitive_summary_format')
|
||||||
let g:fugitive_summary_format = '%s'
|
let g:fugitive_summary_format = '%s'
|
||||||
@@ -2156,7 +2158,7 @@ function! s:Log(cmd, bang, line1, line2, ...) abort
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gedit, Gpedit, Gsplit, Gvsplit, Gtabedit, Gread
|
" Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread
|
||||||
|
|
||||||
function! s:UsableWin(nr) abort
|
function! s:UsableWin(nr) abort
|
||||||
return a:nr && !getwinvar(a:nr, '&previewwindow') &&
|
return a:nr && !getwinvar(a:nr, '&previewwindow') &&
|
||||||
@@ -2299,7 +2301,7 @@ call s:command("-bar -bang -nargs=* -range=0 -complete=customlist,s:EditRunComp
|
|||||||
call s:command("-bar -bang -nargs=* -range=0 -complete=customlist,s:EditRunComplete" . (has('patch-7.4.542') ? ' -addr=tabs' : '') . " Gtabedit execute s:Edit((<count> ? <count> : '').'tabedit', <bang>0, '<mods>', <q-args>, <f-args>)")
|
call s:command("-bar -bang -nargs=* -range=0 -complete=customlist,s:EditRunComplete" . (has('patch-7.4.542') ? ' -addr=tabs' : '') . " Gtabedit execute s:Edit((<count> ? <count> : '').'tabedit', <bang>0, '<mods>', <q-args>, <f-args>)")
|
||||||
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:EditRunComplete Gread execute s:Read(<count>, <line1>, <line2>, +'<range>', <bang>0, '<mods>', <q-args>, <f-args>)")
|
call s:command("-bar -bang -nargs=* -range=-1 -complete=customlist,s:EditRunComplete Gread execute s:Read(<count>, <line1>, <line2>, +'<range>', <bang>0, '<mods>', <q-args>, <f-args>)")
|
||||||
|
|
||||||
" Section: Gwrite, Gwq
|
" Section: :Gwrite, :Gwq
|
||||||
|
|
||||||
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gwrite :execute s:Write(<bang>0,<f-args>)")
|
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gwrite :execute s:Write(<bang>0,<f-args>)")
|
||||||
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gw :execute s:Write(<bang>0,<f-args>)")
|
call s:command("-bar -bang -nargs=* -complete=customlist,fugitive#Complete Gw :execute s:Write(<bang>0,<f-args>)")
|
||||||
@@ -2464,7 +2466,7 @@ augroup fugitive_commit
|
|||||||
autocmd VimLeavePre,BufDelete COMMIT_EDITMSG execute s:sub(s:FinishCommit(), '^echoerr (.*)', 'echohl ErrorMsg|echo \1|echohl NONE')
|
autocmd VimLeavePre,BufDelete COMMIT_EDITMSG execute s:sub(s:FinishCommit(), '^echoerr (.*)', 'echohl ErrorMsg|echo \1|echohl NONE')
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Section: Gpush, Gfetch
|
" Section: :Gpush, :Gfetch
|
||||||
|
|
||||||
call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gpush execute s:Dispatch('<bang>', 'push '.<q-args>)")
|
call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gpush execute s:Dispatch('<bang>', 'push '.<q-args>)")
|
||||||
call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gfetch execute s:Dispatch('<bang>', 'fetch '.<q-args>)")
|
call s:command("-nargs=? -bang -complete=custom,s:RemoteComplete Gfetch execute s:Dispatch('<bang>', 'fetch '.<q-args>)")
|
||||||
@@ -2493,7 +2495,7 @@ function! s:Dispatch(bang, args)
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gdiff
|
" Section: :Gdiff
|
||||||
|
|
||||||
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gdiff :execute s:Diff('',<bang>0,<f-args>)")
|
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gdiff :execute s:Diff('',<bang>0,<f-args>)")
|
||||||
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gvdiff :execute s:Diff('keepalt vert ',<bang>0,<f-args>)")
|
call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#Complete Gvdiff :execute s:Diff('keepalt vert ',<bang>0,<f-args>)")
|
||||||
@@ -2693,7 +2695,7 @@ function! s:Diff(vert,keepfocus,...) abort
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gmove, Gremove
|
" Section: :Gmove, :Gremove
|
||||||
|
|
||||||
function! s:Move(force, rename, destination) abort
|
function! s:Move(force, rename, destination) abort
|
||||||
if a:destination =~# '^\./.'
|
if a:destination =~# '^\./.'
|
||||||
@@ -2772,7 +2774,7 @@ augroup fugitive_remove
|
|||||||
\ endif
|
\ endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Section: Gblame
|
" Section: :Gblame
|
||||||
|
|
||||||
function! s:Keywordprg() abort
|
function! s:Keywordprg() abort
|
||||||
let args = ' --git-dir='.escape(b:git_dir,"\\\"' ")
|
let args = ' --git-dir='.escape(b:git_dir,"\\\"' ")
|
||||||
@@ -3074,7 +3076,7 @@ function! s:RehighlightBlame() abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Gbrowse
|
" Section: :Gbrowse
|
||||||
|
|
||||||
call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,fugitive#Complete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
|
call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,fugitive#Complete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
|
||||||
|
|
||||||
@@ -3698,3 +3700,5 @@ endfunction
|
|||||||
function! fugitive#detect(path) abort
|
function! fugitive#detect(path) abort
|
||||||
return FugitiveDetect(a:path)
|
return FugitiveDetect(a:path)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Section: End
|
||||||
|
|||||||
Reference in New Issue
Block a user