1
0
mirror of https://github.com/amix/vimrc synced 2025-06-29 19:34:59 +08:00

Updated plugins

This commit is contained in:
Amir
2024-10-06 10:25:50 +02:00
parent ee7e062909
commit 46294d589d
202 changed files with 306918 additions and 203617 deletions

View File

@ -118,11 +118,16 @@ endfunction
" }}}
function! gitgutter#git()
" Optional argument is buffer number
function! gitgutter#git(...)
let git = g:gitgutter_git_executable
if a:0
let git .= ' -C '.gitgutter#utility#dir(a:1)
endif
if empty(g:gitgutter_git_args)
return g:gitgutter_git_executable
return git
else
return g:gitgutter_git_executable.' '.g:gitgutter_git_args
return git.' '.g:gitgutter_git_args
endif
endfunction
@ -258,9 +263,7 @@ function! gitgutter#difforig()
if g:gitgutter_diff_relative_to ==# 'index'
let index_name = gitgutter#utility#get_diff_base(bufnr).':'.gitgutter#utility#base_path(bufnr)
let cmd = gitgutter#utility#cd_cmd(bufnr,
\ gitgutter#git().' --no-pager show '.index_name
\ )
let cmd = gitgutter#git(bufnr).' --no-pager show '.index_name
" NOTE: this uses &shell to execute cmd. Perhaps we should use instead
" gitgutter#utility's use_known_shell() / restore_shell() functions.
silent! execute "read ++edit !" cmd

View File

@ -46,7 +46,7 @@ function! s:build_command(cmd)
endif
if has('win32')
return has('nvim') ? ['cmd.exe', '/c', a:cmd] : 'cmd.exe /c '.a:cmd
return has('nvim') ? a:cmd : 'cmd.exe /c '.a:cmd
endif
throw 'unknown os'

View File

@ -116,14 +116,14 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
" Write file from index to temporary file.
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#base_path(a:bufnr)
let cmd .= gitgutter#git().' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
elseif a:from ==# 'working_tree'
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
endif
" Call git-diff.
let cmd .= gitgutter#git().' --no-pager'
let cmd .= gitgutter#git(a:bufnr).' --no-pager'
if gitgutter#utility#git_supports_command_line_config_override()
let cmd .= ' -c "diff.autorefreshindex=0"'
let cmd .= ' -c "diff.noprefix=false"'
@ -144,8 +144,6 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
let cmd .= ')'
let cmd = gitgutter#utility#cd_cmd(a:bufnr, cmd)
if g:gitgutter_async && gitgutter#async#available()
call gitgutter#async#execute(cmd, a:bufnr, {
\ 'out': function('gitgutter#diff#handler'),

View File

@ -60,7 +60,8 @@ function! gitgutter#hunk#next_hunk(count) abort
if hunk[2] > current_line
let hunk_count += 1
if hunk_count == a:count
execute 'normal!' hunk[2] . 'Gzv'
let keys = &foldopen =~# '\<block\>' ? 'zv' : ''
execute 'normal!' hunk[2] . 'G' . keys
if g:gitgutter_show_msg_on_hunk_jumping
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
endif
@ -90,8 +91,9 @@ function! gitgutter#hunk#prev_hunk(count) abort
if hunk[2] < current_line
let hunk_count += 1
if hunk_count == a:count
let keys = &foldopen =~# '\<block\>' ? 'zv' : ''
let target = hunk[2] == 0 ? 1 : hunk[2]
execute 'normal!' target . 'Gzv'
execute 'normal!' target . 'G' . keys
if g:gitgutter_show_msg_on_hunk_jumping
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
endif
@ -306,9 +308,8 @@ function! s:stage(hunk_diff)
write
let path = gitgutter#utility#repo_path(bufnr, 1)
" Add file to index.
let cmd = gitgutter#utility#cd_cmd(bufnr,
\ gitgutter#git().' add '.
\ gitgutter#utility#shellescape(gitgutter#utility#filename(bufnr)))
let cmd = gitgutter#git(bufnr).' add '.
\ gitgutter#utility#shellescape(gitgutter#utility#filename(bufnr))
let [_, error_code] = gitgutter#utility#system(cmd)
else
return
@ -318,7 +319,7 @@ function! s:stage(hunk_diff)
let diff = s:adjust_header(bufnr, a:hunk_diff)
" Apply patch to index.
let [_, error_code] = gitgutter#utility#system(
\ gitgutter#utility#cd_cmd(bufnr, gitgutter#git().' apply --cached --unidiff-zero - '),
\ gitgutter#git(bufnr).' apply --cached --unidiff-zero - ',
\ diff)
endif

View File

@ -66,7 +66,7 @@ function! gitgutter#utility#is_active(bufnr) abort
endfunction
function! s:not_git_dir(bufnr) abort
return s:dir(a:bufnr) !~ '[/\\]\.git\($\|[/\\]\)'
return gitgutter#utility#dir(a:bufnr) !~ '[/\\]\.git\($\|[/\\]\)'
endfunction
function! s:is_file_buffer(bufnr) abort
@ -162,9 +162,8 @@ function! gitgutter#utility#set_repo_path(bufnr, continuation) abort
" * -3 - assume unchanged
call gitgutter#utility#setbufvar(a:bufnr, 'path', -1)
let cmd = gitgutter#utility#cd_cmd(a:bufnr,
\ gitgutter#git().' ls-files -v --error-unmatch --full-name -z -- '.
\ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr)))
let cmd = gitgutter#git(a:bufnr).' ls-files -v --error-unmatch --full-name -z -- '.
\ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr))
if g:gitgutter_async && gitgutter#async#available() && !has('vim_starting')
let handler = copy(s:set_path_handler)
@ -193,9 +192,8 @@ endfunction
function! gitgutter#utility#clean_smudge_filter_applies(bufnr)
let filtered = gitgutter#utility#getbufvar(a:bufnr, 'filter', -1)
if filtered == -1
let cmd = gitgutter#utility#cd_cmd(a:bufnr,
\ gitgutter#git().' check-attr filter -- '.
\ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr)))
let cmd = gitgutter#git(a:bufnr).' check-attr filter -- '.
\ gitgutter#utility#shellescape(gitgutter#utility#filename(a:bufnr))
let [out, _] = gitgutter#utility#system(cmd)
let filtered = out !~ 'unspecified'
call gitgutter#utility#setbufvar(a:bufnr, 'filter', filtered)
@ -204,19 +202,6 @@ function! gitgutter#utility#clean_smudge_filter_applies(bufnr)
endfunction
function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() && s:dos_shell() ? 'cd /d' : 'cd')
return cd.' '.s:dir(a:bufnr).' && '.a:cmd
endfunction
function! s:unc_path(bufnr)
return s:abs_path(a:bufnr, 0) =~ '^\\\\'
endfunction
function! s:dos_shell()
return &shell == 'cmd.exe' || &shell == 'command.com'
endfunction
function! s:use_known_shell() abort
if has('unix') && &shell !=# 'sh'
let [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] = [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote]
@ -303,12 +288,12 @@ endfunction
" Returns a dict of current path to original path at the given base.
function! s:obtain_file_renames(bufnr, base)
let renames = {}
let cmd = gitgutter#git()
let cmd = gitgutter#git(a:bufnr)
if gitgutter#utility#git_supports_command_line_config_override()
let cmd .= ' -c "core.safecrlf=false"'
endif
let cmd .= ' diff --diff-filter=R --name-status '.a:base
let [out, error_code] = gitgutter#utility#system(gitgutter#utility#cd_cmd(a:bufnr, cmd))
let [out, error_code] = gitgutter#utility#system(cmd)
if error_code
" Assume the problem is the diff base.
call gitgutter#utility#warn('g:gitgutter_diff_base ('.a:base.') is invalid')
@ -335,7 +320,8 @@ function! s:abs_path(bufnr, shellesc)
return a:shellesc ? gitgutter#utility#shellescape(p) : p
endfunction
function! s:dir(bufnr) abort
" Shellescaped
function! gitgutter#utility#dir(bufnr) abort
return gitgutter#utility#shellescape(fnamemodify(s:abs_path(a:bufnr, 0), ':h'))
endfunction