1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-10 11:35:49 +08:00
SpaceVim/bundle/git.vim/autoload/git/rm.vim

51 lines
1.2 KiB
VimL
Raw Normal View History

2021-08-01 13:30:23 +08:00
""
" @section git-rm, rm
" @parentsection commands
" This commands is to rm file contents to the index. For example, rm current
" file to the index.
" >
" :Git rm %
" <
if has('nvim-0.9.0')
function! git#rm#complete(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("git.command.rm").complete(vim.api.nvim_eval("a:ArgLead"), vim.api.nvim_eval("a:CmdLine"), vim.api.nvim_eval("a:CursorPos"))')
endfunction
else
let s:JOB = SpaceVim#api#import('job')
2021-08-01 13:30:23 +08:00
function! git#rm#run(files) abort
2021-08-01 13:30:23 +08:00
if len(a:files) == 1 && a:files[0] ==# '%'
let cmd = ['git', 'rm', expand('%')]
2021-08-01 13:30:23 +08:00
else
let cmd = ['git', 'rm'] + a:files
2021-08-01 13:30:23 +08:00
endif
call git#logger#debug('git-rm cmd:' . string(cmd))
2021-08-01 13:30:23 +08:00
call s:JOB.start(cmd,
\ {
\ 'on_exit' : function('s:on_exit'),
\ }
\ )
2021-08-01 13:30:23 +08:00
endfunction
2021-08-01 13:30:23 +08:00
function! s:on_exit(id, data, event) abort
call git#logger#debug('git-rm exit data:' . string(a:data))
2021-08-01 13:30:23 +08:00
if a:data ==# 0
if exists(':GitGutter')
GitGutter
endif
echo 'done!'
2021-08-01 13:30:23 +08:00
else
echo 'failed!'
2021-08-01 13:30:23 +08:00
endif
endfunction
2021-08-01 13:30:23 +08:00
function! git#rm#complete(ArgLead, CmdLine, CursorPos) abort
2021-08-01 13:30:23 +08:00
return "%\n" . join(getcompletion(a:ArgLead, 'file'), "\n")
endfunction
endif