New sy#utils.vim
This commit is contained in:
parent
b28fbe2625
commit
7d4759866a
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
!.gitignore
|
!.gitignore
|
||||||
!CONTRIBUTING.md
|
!CONTRIBUTING.md
|
||||||
!README.md
|
!README.md
|
||||||
|
!autoload/sy/utils.vim
|
||||||
!doc/signify.txt
|
!doc/signify.txt
|
||||||
!plugin/signify.vim
|
!plugin/signify.vim
|
||||||
!showcolors.bash
|
!showcolors.bash
|
||||||
|
27
autoload/sy/utils.vim
Normal file
27
autoload/sy/utils.vim
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
if exists('b:autoloaded_sy_utils')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:autoloaded_sy_utils = 1
|
||||||
|
|
||||||
|
" Function: #escape {{{1
|
||||||
|
function! sy#utils#escape(path) abort
|
||||||
|
if exists('+shellslash')
|
||||||
|
let old_ssl = &shellslash
|
||||||
|
set noshellslash
|
||||||
|
endif
|
||||||
|
|
||||||
|
let path = shellescape(a:path)
|
||||||
|
|
||||||
|
if exists('old_ssl')
|
||||||
|
let &shellslash = old_ssl
|
||||||
|
endif
|
||||||
|
|
||||||
|
return path
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Function: #separator {{{1
|
||||||
|
function! sy#utils#separator() abort
|
||||||
|
return !exists('+shellslash') || &shellslash ? '/' : '\'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" vim: et sw=2 sts=2
|
@ -267,7 +267,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_git {{{1
|
" Function: s:repo_get_diff_git {{{1
|
||||||
function! s:repo_get_diff_git(path) abort
|
function! s:repo_get_diff_git(path) abort
|
||||||
if executable('git')
|
if executable('git')
|
||||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. s:escape(a:path))
|
let diff = system('cd '. sy#utils#escape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. sy#utils#escape(a:path))
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -281,7 +281,7 @@ function! s:repo_get_stat_git() abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let root = fnamemodify(root, ':h')
|
let root = fnamemodify(root, ':h')
|
||||||
let output = system('cd '. s:escape(root) .' && git diff --numstat')
|
let output = system('cd '. sy#utils#escape(root) .' && git diff --numstat')
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
echohl ErrorMsg | echomsg "'git diff --numstat' failed" | echohl None
|
echohl ErrorMsg | echomsg "'git diff --numstat' failed" | echohl None
|
||||||
return
|
return
|
||||||
@ -293,7 +293,7 @@ function! s:repo_get_stat_git() abort
|
|||||||
elseif tokens[1] == '-'
|
elseif tokens[1] == '-'
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
let path = root . s:separator() . tokens[3]
|
let path = root . sy#utils#separator() . tokens[3]
|
||||||
if !bufexists(path)
|
if !bufexists(path)
|
||||||
execute 'argadd '. path
|
execute 'argadd '. path
|
||||||
endif
|
endif
|
||||||
@ -306,7 +306,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_hg {{{1
|
" Function: s:repo_get_diff_hg {{{1
|
||||||
function! s:repo_get_diff_hg(path) abort
|
function! s:repo_get_diff_hg(path) abort
|
||||||
if executable('hg')
|
if executable('hg')
|
||||||
let diff = system('hg diff --nodates -U0 -- '. s:escape(a:path))
|
let diff = system('hg diff --nodates -U0 -- '. sy#utils#escape(a:path))
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -314,7 +314,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_svn {{{1
|
" Function: s:repo_get_diff_svn {{{1
|
||||||
function! s:repo_get_diff_svn(path) abort
|
function! s:repo_get_diff_svn(path) abort
|
||||||
if executable('svn')
|
if executable('svn')
|
||||||
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 -- '. s:escape(a:path))
|
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 -- '. sy#utils#escape(a:path))
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -322,7 +322,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_bzr {{{1
|
" Function: s:repo_get_diff_bzr {{{1
|
||||||
function! s:repo_get_diff_bzr(path) abort
|
function! s:repo_get_diff_bzr(path) abort
|
||||||
if executable('bzr')
|
if executable('bzr')
|
||||||
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 -- '. s:escape(a:path))
|
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 -- '. sy#utils#escape(a:path))
|
||||||
return ((v:shell_error == 0) || (v:shell_error == 1) || (v:shell_error == 2)) ? diff : ''
|
return ((v:shell_error == 0) || (v:shell_error == 1) || (v:shell_error == 2)) ? diff : ''
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -330,7 +330,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_darcs {{{1
|
" Function: s:repo_get_diff_darcs {{{1
|
||||||
function! s:repo_get_diff_darcs(path) abort
|
function! s:repo_get_diff_darcs(path) abort
|
||||||
if executable('darcs')
|
if executable('darcs')
|
||||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" -- '. s:escape(a:path))
|
let diff = system('cd '. sy#utils#escape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" -- '. sy#utils#escape(a:path))
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -338,7 +338,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_fossil {{{1
|
" Function: s:repo_get_diff_fossil {{{1
|
||||||
function! s:repo_get_diff_fossil(path) abort
|
function! s:repo_get_diff_fossil(path) abort
|
||||||
if executable('fossil')
|
if executable('fossil')
|
||||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && fossil set diff-command "'. s:difftool .' -U 0" && fossil diff --unified -c 0 -- '. s:escape(a:path))
|
let diff = system('cd '. sy#utils#escape(fnamemodify(a:path, ':h')) .' && fossil set diff-command "'. s:difftool .' -U 0" && fossil diff --unified -c 0 -- '. sy#utils#escape(a:path))
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -346,7 +346,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_cvs {{{1
|
" Function: s:repo_get_diff_cvs {{{1
|
||||||
function! s:repo_get_diff_cvs(path) abort
|
function! s:repo_get_diff_cvs(path) abort
|
||||||
if executable('cvs')
|
if executable('cvs')
|
||||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. s:escape(fnamemodify(a:path, ':t')))
|
let diff = system('cd '. sy#utils#escape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. sy#utils#escape(fnamemodify(a:path, ':t')))
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -354,7 +354,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_rcs {{{1
|
" Function: s:repo_get_diff_rcs {{{1
|
||||||
function! s:repo_get_diff_rcs(path) abort
|
function! s:repo_get_diff_rcs(path) abort
|
||||||
if executable('rcs')
|
if executable('rcs')
|
||||||
let diff = system('rcsdiff -U0 '. s:escape(a:path) .' 2>/dev/null')
|
let diff = system('rcsdiff -U0 '. sy#utils#escape(a:path) .' 2>/dev/null')
|
||||||
return v:shell_error ? '' : diff
|
return v:shell_error ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -362,7 +362,7 @@ endfunction
|
|||||||
" Function: s:repo_get_diff_accurev {{{1
|
" Function: s:repo_get_diff_accurev {{{1
|
||||||
function! s:repo_get_diff_accurev(path) abort
|
function! s:repo_get_diff_accurev(path) abort
|
||||||
if executable('accurev')
|
if executable('accurev')
|
||||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && accurev diff '. s:escape(fnamemodify(a:path, ':t')) . ' -- -U0')
|
let diff = system('cd '. sy#utils#escape(fnamemodify(a:path, ':h')) .' && accurev diff '. sy#utils#escape(fnamemodify(a:path, ':t')) . ' -- -U0')
|
||||||
return (v:shell_error != 1) ? '' : diff
|
return (v:shell_error != 1) ? '' : diff
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -584,27 +584,6 @@ function! s:jump_to_prev_hunk(count)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:escape {{{1
|
|
||||||
function! s:escape(path) abort
|
|
||||||
if exists('+shellslash')
|
|
||||||
let old_ssl = &shellslash
|
|
||||||
set noshellslash
|
|
||||||
endif
|
|
||||||
|
|
||||||
let path = shellescape(a:path)
|
|
||||||
|
|
||||||
if exists('old_ssl')
|
|
||||||
let &shellslash = old_ssl
|
|
||||||
endif
|
|
||||||
|
|
||||||
return path
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:separator {{{1
|
|
||||||
function! s:separator() abort
|
|
||||||
return !exists('+shellslash') || &shellslash ? '/' : '\'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: SignifyDebugListActiveBuffers {{{1
|
" Function: SignifyDebugListActiveBuffers {{{1
|
||||||
function! SignifyDebugListActiveBuffers() abort
|
function! SignifyDebugListActiveBuffers() abort
|
||||||
if empty(s:sy)
|
if empty(s:sy)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user