From 5d11ff75014818da25596a89cea71df680e31788 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 1 Jun 2018 13:46:22 -0400 Subject: [PATCH] Extract autoload file --- autoload/fugitive.vim | 3076 +++++++++++++++++++++++++++++++++++++++++ plugin/fugitive.vim | 3065 +--------------------------------------- 2 files changed, 3077 insertions(+), 3064 deletions(-) create mode 100644 autoload/fugitive.vim diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim new file mode 100644 index 0000000..58cfa85 --- /dev/null +++ b/autoload/fugitive.vim @@ -0,0 +1,3076 @@ +" Location: autoload/fugitive.vim +" Maintainer: Tim Pope + +if exists('g:autoloaded_fugitive') + finish +endif +let g:autoloaded_fugitive = 1 + +if !exists('g:fugitive_git_executable') + let g:fugitive_git_executable = 'git' +endif + +" Section: Utility + +function! s:function(name) abort + return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) +endfunction + +function! s:sub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'') +endfunction + +function! s:gsub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'g') +endfunction + +function! s:winshell() abort + return &shell =~? 'cmd' || exists('+shellslash') && !&shellslash +endfunction + +function! s:shellesc(arg) abort + if a:arg =~ '^[A-Za-z0-9_/.-]\+$' + return a:arg + elseif s:winshell() + return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"' + else + return shellescape(a:arg) + endif +endfunction + +function! s:fnameescape(file) abort + if exists('*fnameescape') + return fnameescape(a:file) + else + return escape(a:file," \t\n*?[{`$\\%#'\"|!<") + endif +endfunction + +function! s:throw(string) abort + let v:errmsg = 'fugitive: '.a:string + throw v:errmsg +endfunction + +function! s:warn(str) abort + echohl WarningMsg + echomsg a:str + echohl None + let v:warningmsg = a:str +endfunction + +function! s:shellslash(path) abort + if s:winshell() + return tr(a:path, '\', '/') + else + return a:path + endif +endfunction + +let s:executables = {} + +function! s:executable(binary) abort + if !has_key(s:executables, a:binary) + let s:executables[a:binary] = executable(a:binary) + endif + return s:executables[a:binary] +endfunction + +let s:git_versions = {} + +function! s:git_command() abort + return get(g:, 'fugitive_git_command', g:fugitive_git_executable) +endfunction + +function! fugitive#git_version(...) abort + if !has_key(s:git_versions, g:fugitive_git_executable) + let s:git_versions[g:fugitive_git_executable] = matchstr(system(g:fugitive_git_executable.' --version'), "\\S\\+\n") + endif + return s:git_versions[g:fugitive_git_executable] +endfunction + +function! s:recall() abort + let rev = s:sub(s:buffer().rev(), '^/', '') + if rev ==# ':' + return matchstr(getline('.'),'^.\=\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$\|^\d\{6} \x\{40\} \d\t\zs.*') + elseif s:buffer().type('tree') + let file = matchstr(getline('.'), '\t\zs.*') + if empty(file) && line('.') > 2 + let file = s:sub(getline('.'), '/$', '') + endif + if !empty(file) && rev !~# ':$' + return rev . '/' . file + else + return rev . file + endif + endif + return rev +endfunction + +function! s:map(mode, lhs, rhs, ...) abort + let flags = (a:0 ? a:1 : '') . (a:rhs =~# '^' ? '' : '