mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 04:23:46 -05:00
Drop support for Vim older than 7.4
This commit is contained in:
@@ -72,14 +72,11 @@ function! s:shellesc(arg) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:fnameescape = " \t\n*?[{`$\\%#'\"|!<"
|
|
||||||
function! s:fnameescape(file) abort
|
function! s:fnameescape(file) abort
|
||||||
if type(a:file) == type([])
|
if type(a:file) == type([])
|
||||||
return join(map(copy(a:file), 's:fnameescape(v:val)'))
|
return join(map(copy(a:file), 's:fnameescape(v:val)'))
|
||||||
elseif exists('*fnameescape')
|
|
||||||
return fnameescape(a:file)
|
|
||||||
else
|
else
|
||||||
return escape(a:file, s:fnameescape)
|
return fnameescape(a:file)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -88,8 +85,8 @@ function! s:throw(string) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:VersionCheck() abort
|
function! s:VersionCheck() abort
|
||||||
if v:version < 703
|
if v:version < 704
|
||||||
return 'return ' . string('echoerr "fugitive: Vim 7.3 or newer required"')
|
return 'return ' . string('echoerr "fugitive: Vim 7.4 or newer required"')
|
||||||
elseif empty(fugitive#GitVersion())
|
elseif empty(fugitive#GitVersion())
|
||||||
let exe = get(s:GitCmd(), 0, '')
|
let exe = get(s:GitCmd(), 0, '')
|
||||||
if len(exe) && !executable(exe)
|
if len(exe) && !executable(exe)
|
||||||
@@ -227,21 +224,13 @@ function! s:TempScript(...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:DoAutocmd(...) abort
|
function! s:DoAutocmd(...) abort
|
||||||
if v:version >= 704 || (v:version == 703 && has('patch442'))
|
return join(map(copy(a:000), "'doautocmd <nomodeline>' . v:val"), '|')
|
||||||
return join(map(copy(a:000), "'doautocmd <nomodeline>' . v:val"), '|')
|
|
||||||
elseif &modelines > 0
|
|
||||||
return 'try|set modelines=0|' . join(map(copy(a:000), "'doautocmd ' . v:val"), '|') . '|finally|set modelines=' . &modelines . '|endtry'
|
|
||||||
else
|
|
||||||
return join(map(copy(a:000), "'doautocmd ' . v:val"), '|')
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
|
||||||
|
|
||||||
function! s:Map(mode, lhs, rhs, ...) abort
|
function! s:Map(mode, lhs, rhs, ...) abort
|
||||||
let maps = []
|
let maps = []
|
||||||
let defer = a:0 && a:1 =~# '<unique>' || get(g:, 'fugitive_defer_to_existing_maps')
|
let defer = a:0 && a:1 =~# '<unique>' || get(g:, 'fugitive_defer_to_existing_maps')
|
||||||
let flags = substitute(a:0 ? a:1 : '', '<unique>', '', '') . (a:rhs =~# '<Plug>' ? '' : '<script>') . s:nowait
|
let flags = substitute(a:0 ? a:1 : '', '<unique>', '', '') . (a:rhs =~# '<Plug>' ? '' : '<script>') . '<nowait>'
|
||||||
for mode in split(a:mode, '\zs')
|
for mode in split(a:mode, '\zs')
|
||||||
if a:0 <= 1
|
if a:0 <= 1
|
||||||
call add(maps, mode.'map <buffer>' . substitute(flags, '<unique>', '', '') . ' <Plug>fugitive:' . a:lhs . ' ' . a:rhs)
|
call add(maps, mode.'map <buffer>' . substitute(flags, '<unique>', '', '') . ' <Plug>fugitive:' . a:lhs . ' ' . a:rhs)
|
||||||
@@ -1970,7 +1959,7 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort
|
|||||||
return expand(a:other)
|
return expand(a:other)
|
||||||
elseif a:var ==# '<cfile>'
|
elseif a:var ==# '<cfile>'
|
||||||
let bufnames = [expand('<cfile>')]
|
let bufnames = [expand('<cfile>')]
|
||||||
if v:version >= 704 && get(maparg('<Plug><cfile>', 'c', 0, 1), 'expr')
|
if get(maparg('<Plug><cfile>', 'c', 0, 1), 'expr')
|
||||||
try
|
try
|
||||||
let bufnames = [eval(maparg('<Plug><cfile>', 'c'))]
|
let bufnames = [eval(maparg('<Plug><cfile>', 'c'))]
|
||||||
if bufnames[0] ==# "\<C-R>\<C-F>"
|
if bufnames[0] ==# "\<C-R>\<C-F>"
|
||||||
@@ -2015,6 +2004,8 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort
|
|||||||
return join(files, "\1")
|
return join(files, "\1")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:fnameescape = " \t\n*?[{`$\\%#'\"|!<"
|
||||||
|
|
||||||
function! s:Expand(rev, ...) abort
|
function! s:Expand(rev, ...) abort
|
||||||
if a:rev =~# '^>' && s:Slash(@%) =~# '^fugitive://' && empty(s:DirCommitFile(@%)[1])
|
if a:rev =~# '^>' && s:Slash(@%) =~# '^fugitive://' && empty(s:DirCommitFile(@%)[1])
|
||||||
return s:Slash(@%)
|
return s:Slash(@%)
|
||||||
@@ -2392,10 +2383,8 @@ endfunction
|
|||||||
function! s:GlobComplete(lead, pattern, ...) abort
|
function! s:GlobComplete(lead, pattern, ...) abort
|
||||||
if a:lead ==# '/'
|
if a:lead ==# '/'
|
||||||
return []
|
return []
|
||||||
elseif v:version >= 704
|
|
||||||
let results = glob(a:lead . a:pattern, a:0 ? a:1 : 0, 1)
|
|
||||||
else
|
else
|
||||||
let results = split(glob(a:lead . a:pattern), "\n")
|
let results = glob(a:lead . a:pattern, a:0 ? a:1 : 0, 1)
|
||||||
endif
|
endif
|
||||||
call map(results, 'v:val !~# "/$" && isdirectory(v:val) ? v:val."/" : v:val')
|
call map(results, 'v:val !~# "/$" && isdirectory(v:val) ? v:val."/" : v:val')
|
||||||
call map(results, 'v:val[ strlen(a:lead) : -1 ]')
|
call map(results, 'v:val[ strlen(a:lead) : -1 ]')
|
||||||
@@ -4296,7 +4285,7 @@ function! fugitive#DidChange(...) abort
|
|||||||
if a:0 > 1 ? a:2 : (!a:0 || a:1 isnot# 0)
|
if a:0 > 1 ? a:2 : (!a:0 || a:1 isnot# 0)
|
||||||
let t = reltime()
|
let t = reltime()
|
||||||
let t:fugitive_reload_status = t
|
let t:fugitive_reload_status = t
|
||||||
for tabnr in exists('*settabvar') ? range(1, tabpagenr('$')) : []
|
for tabnr in range(1, tabpagenr('$'))
|
||||||
call settabvar(tabnr, 'fugitive_reload_status', t)
|
call settabvar(tabnr, 'fugitive_reload_status', t)
|
||||||
endfor
|
endfor
|
||||||
call s:ReloadTabStatus()
|
call s:ReloadTabStatus()
|
||||||
@@ -6414,32 +6403,14 @@ function! s:diff_window_count() abort
|
|||||||
return c
|
return c
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:diff_restore() abort
|
|
||||||
let restore = 'setlocal nodiff noscrollbind'
|
|
||||||
\ . ' scrollopt=' . &l:scrollopt
|
|
||||||
\ . (&l:wrap ? ' wrap' : ' nowrap')
|
|
||||||
\ . ' foldlevel=999'
|
|
||||||
\ . ' foldmethod=' . &l:foldmethod
|
|
||||||
\ . ' foldcolumn=' . &l:foldcolumn
|
|
||||||
\ . ' foldlevel=' . &l:foldlevel
|
|
||||||
\ . (&l:foldenable ? ' foldenable' : ' nofoldenable')
|
|
||||||
if has('cursorbind')
|
|
||||||
let restore .= (&l:cursorbind ? ' ' : ' no') . 'cursorbind'
|
|
||||||
endif
|
|
||||||
return restore
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:diffthis() abort
|
function! s:diffthis() abort
|
||||||
if !&diff
|
if !&diff
|
||||||
let w:fugitive_diff_restore = s:diff_restore()
|
let w:fugitive_diff_restore = 1
|
||||||
diffthis
|
diffthis
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:diffoff() abort
|
function! s:diffoff() abort
|
||||||
if exists('w:fugitive_diff_restore') && v:version < 704
|
|
||||||
execute w:fugitive_diff_restore
|
|
||||||
endif
|
|
||||||
unlet! w:fugitive_diff_restore
|
unlet! w:fugitive_diff_restore
|
||||||
diffoff
|
diffoff
|
||||||
endfunction
|
endfunction
|
||||||
@@ -6448,12 +6419,6 @@ function! s:diffoff_all(dir) abort
|
|||||||
let curwin = winnr()
|
let curwin = winnr()
|
||||||
for nr in range(1,winnr('$'))
|
for nr in range(1,winnr('$'))
|
||||||
if getwinvar(nr, '&diff') && !empty(getwinvar(nr, 'fugitive_diff_restore'))
|
if getwinvar(nr, '&diff') && !empty(getwinvar(nr, 'fugitive_diff_restore'))
|
||||||
if v:version < 704
|
|
||||||
if nr != winnr()
|
|
||||||
execute nr.'wincmd w'
|
|
||||||
endif
|
|
||||||
execute w:fugitive_diff_restore
|
|
||||||
endif
|
|
||||||
call setwinvar(nr, 'fugitive_diff_restore', '')
|
call setwinvar(nr, 'fugitive_diff_restore', '')
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -6583,15 +6548,14 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, ...) abort
|
|||||||
let spec = s:VimSlash(spec . s:Relative('/'))
|
let spec = s:VimSlash(spec . s:Relative('/'))
|
||||||
endif
|
endif
|
||||||
exe pre
|
exe pre
|
||||||
let restore = s:diff_restore()
|
let w:fugitive_diff_restore = 1
|
||||||
let w:fugitive_diff_restore = restore
|
|
||||||
let mods = (autodir ? s:DiffModifier(2, empty(args) || args[0] =~# '^>') : '') . mods
|
let mods = (autodir ? s:DiffModifier(2, empty(args) || args[0] =~# '^>') : '') . mods
|
||||||
if &diffopt =~# 'vertical'
|
if &diffopt =~# 'vertical'
|
||||||
let diffopt = &diffopt
|
let diffopt = &diffopt
|
||||||
set diffopt-=vertical
|
set diffopt-=vertical
|
||||||
endif
|
endif
|
||||||
execute mods 'diffsplit' s:fnameescape(spec)
|
execute mods 'diffsplit' s:fnameescape(spec)
|
||||||
let w:fugitive_diff_restore = restore
|
let w:fugitive_diff_restore = 1
|
||||||
let winnr = winnr()
|
let winnr = winnr()
|
||||||
if getwinvar('#', '&diff')
|
if getwinvar('#', '&diff')
|
||||||
if a:keepfocus
|
if a:keepfocus
|
||||||
@@ -6733,7 +6697,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:linechars(pattern) abort
|
function! s:linechars(pattern) abort
|
||||||
let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
||||||
if exists('*synconcealed') && &conceallevel > 1
|
if &conceallevel > 1
|
||||||
for col in range(1, chars)
|
for col in range(1, chars)
|
||||||
let chars -= synconcealed(line('.'), col)[0]
|
let chars -= synconcealed(line('.'), col)[0]
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ let s:bad_git_dir = '/$\|^fugitive:'
|
|||||||
" Fugitive is active in the current buffer. Do not rely on this for direct
|
" Fugitive is active in the current buffer. Do not rely on this for direct
|
||||||
" filesystem access; use FugitiveFind('.git/whatever') instead.
|
" filesystem access; use FugitiveFind('.git/whatever') instead.
|
||||||
function! FugitiveGitDir(...) abort
|
function! FugitiveGitDir(...) abort
|
||||||
if v:version < 703
|
if v:version < 704
|
||||||
return ''
|
return ''
|
||||||
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
|
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
|
||||||
if exists('g:fugitive_event')
|
if exists('g:fugitive_event')
|
||||||
@@ -463,7 +463,7 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveDetect(...) abort
|
function! FugitiveDetect(...) abort
|
||||||
if v:version < 703
|
if v:version < 704
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
|
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
|
||||||
@@ -645,7 +645,7 @@ elseif exists(':Gbrowse') != 2 && !exists('g:fugitive_legacy_commands')
|
|||||||
\ 'echoerr ":Gbrowse has been removed in favor of :GBrowse"'
|
\ 'echoerr ":Gbrowse has been removed in favor of :GBrowse"'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if v:version < 703
|
if v:version < 704
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -730,10 +730,8 @@ if get(g:, 'fugitive_no_maps')
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
|
||||||
|
|
||||||
function! s:Map(mode, lhs, rhs, flags) abort
|
function! s:Map(mode, lhs, rhs, flags) abort
|
||||||
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>') . '<nowait>'
|
||||||
let head = a:lhs
|
let head = a:lhs
|
||||||
let tail = ''
|
let tail = ''
|
||||||
let keys = get(g:, a:mode.'remap', {})
|
let keys = get(g:, a:mode.'remap', {})
|
||||||
@@ -751,7 +749,7 @@ function! s:Map(mode, lhs, rhs, flags) abort
|
|||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
if empty(mapcheck(head.tail, a:mode))
|
if empty(mapcheck(head.tail, a:mode))
|
||||||
exe a:mode.'map' s:nowait flags head.tail a:rhs
|
exe a:mode.'map' flags head.tail a:rhs
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user