1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
Amir
2020-12-04 22:15:32 +01:00
parent e83f5ea2e7
commit a06964dd3b
261 changed files with 6955 additions and 2773 deletions

View File

@ -146,11 +146,13 @@ endif
function! s:TempScript(...) abort
let body = join(a:000, "\n")
if !has_key(s:temp_scripts, body)
let temp = tempname() . '.sh'
call writefile(['#!/bin/sh'] + a:000, temp)
let s:temp_scripts[body] = temp
let s:temp_scripts[body] = tempname() . '.sh'
endif
return FugitiveGitPath(s:temp_scripts[body])
let temp = s:temp_scripts[body]
if !filereadable(temp)
call writefile(['#!/bin/sh'] + a:000, temp)
endif
return FugitiveGitPath(temp)
endfunction
function! s:DoAutocmd(cmd) abort
@ -551,9 +553,9 @@ function! fugitive#Config(...) abort
let dir = a:1
endif
let name = substitute(name, '^[^.]\+\|[^.]\+$', '\L&', 'g')
let key = len(dir) ? dir : '_'
if has_key(s:config, key) && s:config[key][0] ==# s:ConfigTimestamps(dir, s:config[key][1])
let dict = s:config[key][1]
let dir_key = len(dir) ? dir : '_'
if has_key(s:config, dir_key) && s:config[dir_key][0] ==# s:ConfigTimestamps(dir, s:config[dir_key][1])
let dict = s:config[dir_key][1]
else
let dict = {}
let [lines, message, exec_error] = s:NullError([dir, 'config', '--list', '-z'])
@ -571,7 +573,7 @@ function! fugitive#Config(...) abort
call add(dict[key], strpart(line, len(key) + 1))
endif
endfor
let s:config[dir] = [s:ConfigTimestamps(dir, dict), dict]
let s:config[dir_key] = [s:ConfigTimestamps(dir, dict), dict]
lockvar! dict
endif
return len(name) ? get(get(dict, name, []), 0, '') : dict
@ -1622,7 +1624,7 @@ endfunction
function! s:CompleteRemote(A, L, P, ...) abort
let dir = a:0 ? a:1 : s:Dir()
let remote = matchstr(a:L, '\u\w*[! ] *\zs\S\+\ze ')
let remote = matchstr(a:L, '\u\w*[! ] *.\{-\}\s\@<=\zs[^-[:space:]]\S*\ze ')
if !empty(remote)
let matches = s:LinesError([dir, 'ls-remote', remote])[0]
call filter(matches, 'v:val =~# "\t" && v:val !~# "{"')
@ -1641,6 +1643,7 @@ function! s:ReplaceCmd(cmd) abort
if exec_error
call s:throw((len(err) ? err : filereadable(temp) ? join(readfile(temp), ' ') : 'unknown error running ' . a:cmd))
endif
setlocal noswapfile
silent exe 'lockmarks keepalt 0read ++edit' s:fnameescape(temp)
if &foldenable && foldlevel('$') > 0
set nofoldenable
@ -1938,6 +1941,10 @@ function! fugitive#BufReadStatus() abort
if empty(s:Tree())
call s:AddHeader('Bare', 'yes')
endif
if get(FugitiveConfigGetAll('advice.statusHints', config), 0, 'true') !~# '^\%(false\|no|off\|0\|\)$'
call s:AddHeader('Help', 'g?')
endif
call s:AddSection('Rebasing ' . rebasing_head, rebasing)
call s:AddSection('Untracked', untracked)
call s:AddSection('Unstaged', unstaged)
@ -2156,13 +2163,13 @@ function! fugitive#BufReadCmd(...) abort
keepjumps 1
keepjumps call search('^parent ')
if getline('.') ==# 'parent '
silent keepjumps delete_
silent lockmarks keepjumps delete_
else
silent exe (exists(':keeppatterns') ? 'keeppatterns' : '') 'keepjumps s/\m\C\%(^parent\)\@<! /\rparent /e' . (&gdefault ? '' : 'g')
endif
keepjumps let lnum = search('^encoding \%(<unknown>\)\=$','W',line('.')+3)
if lnum
silent keepjumps delete_
silent lockmarks keepjumps delete_
end
silent exe (exists(':keeppatterns') ? 'keeppatterns' : '') 'keepjumps 1,/^diff --git\|\%$/s/\r$//e'
keepjumps 1
@ -2639,14 +2646,15 @@ endfunction
let s:aliases = {}
function! s:Aliases(dir) abort
if !has_key(s:aliases, a:dir)
let s:aliases[a:dir] = {}
let dir_key = len(a:dir) ? a:dir : '_'
if !has_key(s:aliases, dir_key)
let s:aliases[dir_key] = {}
let lines = s:NullError([a:dir, 'config', '-z', '--get-regexp', '^alias[.]'])[0]
for line in lines
let s:aliases[a:dir][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*')
let s:aliases[dir_key][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*')
endfor
endif
return s:aliases[a:dir]
return s:aliases[dir_key]
endfunction
function! fugitive#Complete(lead, ...) abort
@ -3521,7 +3529,12 @@ function! s:StageApply(info, reverse, extra) abort
let i = b:fugitive_expanded[info.section][info.filename][0]
let head = []
while get(b:fugitive_diff[info.section], i, '@') !~# '^@'
call add(head, b:fugitive_diff[info.section][i])
let line = b:fugitive_diff[info.section][i]
if line ==# '--- /dev/null'
call add(head, '--- ' . get(b:fugitive_diff[info.section], i + 1, '')[4:-1])
elseif line !~# '^new file '
call add(head, line)
endif
let i += 1
endwhile
call extend(lines, head, 'keep')
@ -3731,7 +3744,7 @@ function! s:DoUnstageStaged(record) abort
endfunction
function! s:DoToggleUnstaged(record) abort
if a:record.patch && a:record.status !=# 'A'
if a:record.patch
return s:StageApply(a:record, 0, ['--cached'])
else
call s:TreeChomp(['add', '-A', '--'] + a:record.paths)
@ -4484,7 +4497,7 @@ function! s:OpenParse(args, wants_cmd) abort
return [url, pre]
endfunction
function! s:DiffClose() abort
function! fugitive#DiffClose() abort
let mywinnr = winnr()
for winnr in [winnr('#')] + range(winnr('$'),1,-1)
if winnr != mywinnr && getwinvar(winnr,'&diff')
@ -4507,7 +4520,7 @@ function! s:BlurStatus() abort
belowright new
endif
if &diff
call s:DiffClose()
call fugitive#DiffClose()
endif
endif
endfunction
@ -4621,10 +4634,8 @@ endfunction
" Section: :Gwrite, :Gwq
function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abort
if exists('b:fugitive_commit_arguments')
return 'write|bdelete'
elseif expand('%:t') == 'COMMIT_EDITMSG' && $GIT_INDEX_FILE != ''
return 'wq'
if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG'))
return (empty($GIT_INDEX_FILE) ? 'write|bdelete' : 'wq') . (a:bang ? '!' : '')
elseif get(b:, 'fugitive_type', '') ==# 'index'
return 'Git commit'
elseif &buftype ==# 'nowrite' && getline(4) =~# '^[+-]\{3\} '
@ -4753,7 +4764,7 @@ endfunction
function! fugitive#WqCommand(...) abort
let bang = a:4 ? '!' : ''
if exists('b:fugitive_commit_arguments')
if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG'))
return 'wq'.bang
endif
let result = call('fugitive#WriteCommand', a:000)
@ -4880,25 +4891,30 @@ function! s:diffthis() abort
endfunction
function! s:diffoff() abort
if exists('w:fugitive_diff_restore')
if exists('w:fugitive_diff_restore') && v:version < 704
execute w:fugitive_diff_restore
unlet w:fugitive_diff_restore
else
diffoff
endif
unlet! w:fugitive_diff_restore
diffoff
endfunction
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 nr != winnr()
execute nr.'wincmd w'
if v:version < 704
if nr != winnr()
execute nr.'wincmd w'
endif
execute w:fugitive_diff_restore
endif
call s:diffoff()
call setwinvar(nr, 'fugitive_diff_restore', '')
endif
endfor
execute curwin.'wincmd w'
if curwin != winnr()
execute curwin.'wincmd w'
endif
diffoff!
endfunction
function! s:CompareAge(mine, theirs) abort
@ -5180,7 +5196,7 @@ endfunction
function! s:BlameCommitFileLnum(...) abort
let line = a:0 ? a:1 : getline('.')
let state = a:0 ? a:2 : s:TempState()
let commit = matchstr(line, '^\^\=\zs\x\+')
let commit = matchstr(line, '^\^\=[?*]*\zs\x\+')
if commit =~# '^0\+$'
let commit = ''
elseif has_key(state, 'blame_reverse_end')
@ -5548,6 +5564,7 @@ let s:hash_colors = {}
function! fugitive#BlameSyntax() abort
let conceal = has('conceal') ? ' conceal' : ''
let flags = get(s:TempState(), 'blame_flags', [])
syn spell notoplevel
syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite
syn match FugitiveblameHash "\%(^\^\=[?*]*\)\@<=\<\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite
syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=\<0\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite
@ -5558,7 +5575,7 @@ function! fugitive#BlameSyntax() abort
endif
syn match FugitiveblameScoreDebug " *\d\+\s\+\d\+\s\@=" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile contained skipwhite
syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%(\s\d\+\)\@<=)" contained keepend oneline
syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%(\s\+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation
syn match FugitiveblameTime "\<[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%(\s\+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation
exec 'syn match FugitiveblameLineNumber "\s*\d\+)\@=" contained containedin=FugitiveblameAnnotation' conceal
exec 'syn match FugitiveblameOriginalFile "\s\%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite' (s:HasOpt(flags, '--show-name', '-f') ? '' : conceal)
exec 'syn match FugitiveblameOriginalLineNumber "\s*\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite' (s:HasOpt(flags, '--show-number', '-n') ? '' : conceal)
@ -5955,11 +5972,11 @@ function! fugitive#MapJumps(...) abort
call s:Map('n', 'gO', ':<C-U>0,4' . blame_map, '<silent>')
call s:Map('n', 'O', ':<C-U>0,5' . blame_map, '<silent>')
call s:Map('n', 'D', ":<C-U>call <SID>DiffClose()<Bar>Gdiffsplit!<Bar>redraw<Bar>echohl WarningMsg<Bar> echo ':Gstatus D is deprecated in favor of dd'<Bar>echohl NONE<CR>", '<silent>')
call s:Map('n', 'dd', ":<C-U>call <SID>DiffClose()<Bar>Gdiffsplit!<CR>", '<silent>')
call s:Map('n', 'dh', ":<C-U>call <SID>DiffClose()<Bar>Ghdiffsplit!<CR>", '<silent>')
call s:Map('n', 'ds', ":<C-U>call <SID>DiffClose()<Bar>Ghdiffsplit!<CR>", '<silent>')
call s:Map('n', 'dv', ":<C-U>call <SID>DiffClose()<Bar>Gvdiffsplit!<CR>", '<silent>')
call s:Map('n', 'D', ":<C-U>call fugitive#DiffClose()<Bar>Gdiffsplit!<Bar>redraw<Bar>echohl WarningMsg<Bar> echo ':Gstatus D is deprecated in favor of dd'<Bar>echohl NONE<CR>", '<silent>')
call s:Map('n', 'dd', ":<C-U>call fugitive#DiffClose()<Bar>Gdiffsplit!<CR>", '<silent>')
call s:Map('n', 'dh', ":<C-U>call fugitive#DiffClose()<Bar>Ghdiffsplit!<CR>", '<silent>')
call s:Map('n', 'ds', ":<C-U>call fugitive#DiffClose()<Bar>Ghdiffsplit!<CR>", '<silent>')
call s:Map('n', 'dv', ":<C-U>call fugitive#DiffClose()<Bar>Gvdiffsplit!<CR>", '<silent>')
call s:Map('n', 'd?', ":<C-U>help fugitive_d<CR>", '<silent>')
else
@ -5996,7 +6013,7 @@ function! fugitive#MapJumps(...) abort
call s:Map('nxo', '#', '<SID>PatchSearchExpr(1)', '<expr>')
endif
call s:Map('n', 'S', ':<C-U>echoerr "Use gO"<CR>', '<silent>')
call s:Map('n', 'dq', ":<C-U>call <SID>DiffClose()<CR>", '<silent>')
call s:Map('n', 'dq', ":<C-U>call fugitive#DiffClose()<CR>", '<silent>')
call s:Map('n', '-', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>", '<silent>')
call s:Map('n', 'P', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>", '<silent>')
call s:Map('n', '~', ":<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR>", '<silent>')