mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Add Git mv command (#4350)
This commit is contained in:
parent
697fec62ea
commit
487f4fa543
@ -31,6 +31,8 @@ function! git#run(...) abort
|
||||
call git#diff#run(a:000[1:])
|
||||
elseif cmd ==# 'rm'
|
||||
call git#rm#run(a:000[1:])
|
||||
elseif cmd ==# 'mv'
|
||||
call git#mv#run(a:000[1:])
|
||||
elseif cmd ==# 'log'
|
||||
call git#log#run(a:000[1:])
|
||||
elseif cmd ==# 'reflog'
|
||||
@ -74,13 +76,15 @@ function! git#complete(ArgLead, CmdLine, CursorPos) abort
|
||||
return join(['add', 'push', 'status', 'commit', 'diff',
|
||||
\ 'merge', 'rebase', 'branch', 'checkout',
|
||||
\ 'fetch', 'reset', 'log', 'config', 'reflog',
|
||||
\ 'blame', 'pull', 'stash', 'cherry-pick', 'rm'
|
||||
\ 'blame', 'pull', 'stash', 'cherry-pick', 'rm', 'mv'
|
||||
\ ],
|
||||
\ "\n")
|
||||
elseif str =~# '^Git\s\+add\s\+.*$'
|
||||
return git#add#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||
elseif str =~# '^Git\s\+rm\s\+.*$'
|
||||
return git#rm#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||
elseif str =~# '^Git\s\+mv\s\+.*$'
|
||||
return git#mv#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||
elseif str =~# '^Git\s\+push\s\+.*$'
|
||||
return git#push#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||
elseif str =~# '^Git\s\+diff\s\+.*$'
|
||||
|
46
bundle/git.vim/autoload/git/mv.vim
Normal file
46
bundle/git.vim/autoload/git/mv.vim
Normal file
@ -0,0 +1,46 @@
|
||||
""
|
||||
" @section git-mv, mv
|
||||
" @parentsection commands
|
||||
" This commands is to run `git mv` command asynchronously.
|
||||
" It is to move file to the index. For example, rename current file.
|
||||
" >
|
||||
" :Git mv % new_file.txt
|
||||
" <
|
||||
|
||||
let s:JOB = SpaceVim#api#import('job')
|
||||
|
||||
function! git#mv#run(args) abort
|
||||
|
||||
let args = a:args
|
||||
if index(a:args, '%') !=# -1
|
||||
let index = index(a:args, '%')
|
||||
let args[index] = expand('%')
|
||||
endif
|
||||
let cmd = ['git', 'mv'] + args
|
||||
call git#logger#info('git-mv cmd:' . string(cmd))
|
||||
call s:JOB.start(cmd,
|
||||
\ {
|
||||
\ 'on_exit' : function('s:on_exit'),
|
||||
\ }
|
||||
\ )
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:on_exit(id, data, event) abort
|
||||
call git#logger#info('git-mv exit data:' . string(a:data))
|
||||
if a:data ==# 0
|
||||
if exists(':GitGutter')
|
||||
GitGutter
|
||||
endif
|
||||
echo 'done!'
|
||||
else
|
||||
echo 'failed!'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! git#rm#complete(ArgLead, CmdLine, CursorPos) abort
|
||||
|
||||
return "%\n" . join(getcompletion(a:ArgLead, 'file'), "\n")
|
||||
|
||||
endfunction
|
||||
|
@ -7,8 +7,9 @@ CONTENTS *git-contents*
|
||||
2. Commands...................................................|git-commands|
|
||||
1. git-add.....................................................|git-add|
|
||||
2. git-cherry-pick.....................................|git-cherry-pick|
|
||||
3. git-rm.......................................................|git-rm|
|
||||
4. git-stash.................................................|git-stash|
|
||||
3. git-mv.......................................................|git-mv|
|
||||
4. git-rm.......................................................|git-rm|
|
||||
5. git-stash.................................................|git-stash|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *git-intro*
|
||||
@ -39,6 +40,15 @@ This command is to cherry pick commit from other branch.
|
||||
:Git cherry-pick <HashA> <HashB>
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
GIT-MV *git-mv*
|
||||
|
||||
This commands is to run `git mv` command asynchronously. It is to move file to
|
||||
the index. For example, rename current file.
|
||||
>
|
||||
:Git mv % new_file.txt
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
GIT-RM *git-rm*
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user