mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -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
|
||||
endfunction
|
||||
|
||||
let s:fnameescape = " \t\n*?[{`$\\%#'\"|!<"
|
||||
function! s:fnameescape(file) abort
|
||||
if type(a:file) == type([])
|
||||
return join(map(copy(a:file), 's:fnameescape(v:val)'))
|
||||
elseif exists('*fnameescape')
|
||||
return fnameescape(a:file)
|
||||
else
|
||||
return escape(a:file, s:fnameescape)
|
||||
return fnameescape(a:file)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -88,8 +85,8 @@ function! s:throw(string) abort
|
||||
endfunction
|
||||
|
||||
function! s:VersionCheck() abort
|
||||
if v:version < 703
|
||||
return 'return ' . string('echoerr "fugitive: Vim 7.3 or newer required"')
|
||||
if v:version < 704
|
||||
return 'return ' . string('echoerr "fugitive: Vim 7.4 or newer required"')
|
||||
elseif empty(fugitive#GitVersion())
|
||||
let exe = get(s:GitCmd(), 0, '')
|
||||
if len(exe) && !executable(exe)
|
||||
@@ -227,21 +224,13 @@ function! s:TempScript(...) abort
|
||||
endfunction
|
||||
|
||||
function! s:DoAutocmd(...) abort
|
||||
if v:version >= 704 || (v:version == 703 && has('patch442'))
|
||||
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
|
||||
return join(map(copy(a:000), "'doautocmd <nomodeline>' . v:val"), '|')
|
||||
endfunction
|
||||
|
||||
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
||||
|
||||
function! s:Map(mode, lhs, rhs, ...) abort
|
||||
let 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')
|
||||
if a:0 <= 1
|
||||
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)
|
||||
elseif a:var ==# '<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
|
||||
let bufnames = [eval(maparg('<Plug><cfile>', 'c'))]
|
||||
if bufnames[0] ==# "\<C-R>\<C-F>"
|
||||
@@ -2015,6 +2004,8 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort
|
||||
return join(files, "\1")
|
||||
endfunction
|
||||
|
||||
let s:fnameescape = " \t\n*?[{`$\\%#'\"|!<"
|
||||
|
||||
function! s:Expand(rev, ...) abort
|
||||
if a:rev =~# '^>' && s:Slash(@%) =~# '^fugitive://' && empty(s:DirCommitFile(@%)[1])
|
||||
return s:Slash(@%)
|
||||
@@ -2392,10 +2383,8 @@ endfunction
|
||||
function! s:GlobComplete(lead, pattern, ...) abort
|
||||
if a:lead ==# '/'
|
||||
return []
|
||||
elseif v:version >= 704
|
||||
let results = glob(a:lead . a:pattern, a:0 ? a:1 : 0, 1)
|
||||
else
|
||||
let results = split(glob(a:lead . a:pattern), "\n")
|
||||
let results = glob(a:lead . a:pattern, a:0 ? a:1 : 0, 1)
|
||||
endif
|
||||
call map(results, 'v:val !~# "/$" && isdirectory(v:val) ? v:val."/" : v:val')
|
||||
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)
|
||||
let t = reltime()
|
||||
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)
|
||||
endfor
|
||||
call s:ReloadTabStatus()
|
||||
@@ -6414,32 +6403,14 @@ function! s:diff_window_count() abort
|
||||
return c
|
||||
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
|
||||
if !&diff
|
||||
let w:fugitive_diff_restore = s:diff_restore()
|
||||
let w:fugitive_diff_restore = 1
|
||||
diffthis
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:diffoff() abort
|
||||
if exists('w:fugitive_diff_restore') && v:version < 704
|
||||
execute w:fugitive_diff_restore
|
||||
endif
|
||||
unlet! w:fugitive_diff_restore
|
||||
diffoff
|
||||
endfunction
|
||||
@@ -6448,12 +6419,6 @@ function! s:diffoff_all(dir) abort
|
||||
let curwin = winnr()
|
||||
for nr in range(1,winnr('$'))
|
||||
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', '')
|
||||
endif
|
||||
endfor
|
||||
@@ -6583,15 +6548,14 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, ...) abort
|
||||
let spec = s:VimSlash(spec . s:Relative('/'))
|
||||
endif
|
||||
exe pre
|
||||
let restore = s:diff_restore()
|
||||
let w:fugitive_diff_restore = restore
|
||||
let w:fugitive_diff_restore = 1
|
||||
let mods = (autodir ? s:DiffModifier(2, empty(args) || args[0] =~# '^>') : '') . mods
|
||||
if &diffopt =~# 'vertical'
|
||||
let diffopt = &diffopt
|
||||
set diffopt-=vertical
|
||||
endif
|
||||
execute mods 'diffsplit' s:fnameescape(spec)
|
||||
let w:fugitive_diff_restore = restore
|
||||
let w:fugitive_diff_restore = 1
|
||||
let winnr = winnr()
|
||||
if getwinvar('#', '&diff')
|
||||
if a:keepfocus
|
||||
@@ -6733,7 +6697,7 @@ endfunction
|
||||
|
||||
function! s:linechars(pattern) abort
|
||||
let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
||||
if exists('*synconcealed') && &conceallevel > 1
|
||||
if &conceallevel > 1
|
||||
for col in range(1, chars)
|
||||
let chars -= synconcealed(line('.'), col)[0]
|
||||
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
|
||||
" filesystem access; use FugitiveFind('.git/whatever') instead.
|
||||
function! FugitiveGitDir(...) abort
|
||||
if v:version < 703
|
||||
if v:version < 704
|
||||
return ''
|
||||
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
|
||||
if exists('g:fugitive_event')
|
||||
@@ -463,7 +463,7 @@ function! FugitiveExtractGitDir(path) abort
|
||||
endfunction
|
||||
|
||||
function! FugitiveDetect(...) abort
|
||||
if v:version < 703
|
||||
if v:version < 704
|
||||
return ''
|
||||
endif
|
||||
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"'
|
||||
endif
|
||||
|
||||
if v:version < 703
|
||||
if v:version < 704
|
||||
finish
|
||||
endif
|
||||
|
||||
@@ -730,10 +730,8 @@ if get(g:, 'fugitive_no_maps')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
||||
|
||||
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 tail = ''
|
||||
let keys = get(g:, a:mode.'remap', {})
|
||||
@@ -751,7 +749,7 @@ function! s:Map(mode, lhs, rhs, flags) abort
|
||||
endwhile
|
||||
endif
|
||||
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
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user