1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-09 18:00:05 +08:00
SpaceVim/bundle/git.vim/autoload/git/reset.vim

51 lines
1.4 KiB
VimL
Raw Normal View History

"=============================================================================
" reset.vim --- git reset command
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
2021-01-02 18:15:08 +08:00
if has('nvim-0.9.0')
function! git#reset#complete(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("git.command.reset").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-01-02 18:15:08 +08:00
function! git#reset#run(args)
2021-01-02 18:15:08 +08:00
if len(a:args) == 1 && a:args[0] ==# '%'
let cmd = ['git', 'reset', 'HEAD', expand('%')]
2021-01-02 18:15:08 +08:00
else
let cmd = ['git', 'reset'] + a:args
2021-01-02 18:15:08 +08:00
endif
call git#logger#debug('git-reset cmd:' . string(cmd))
2021-01-02 18:15:08 +08:00
call s:JOB.start(cmd,
\ {
\ 'on_exit' : function('s:on_exit'),
\ }
\ )
2021-01-02 18:15:08 +08:00
endfunction
2021-01-02 18:15:08 +08:00
function! s:on_exit(id, data, event) abort
call git#logger#debug('git-reset exit data:' . string(a:data))
2021-01-02 18:15:08 +08:00
if a:data ==# 0
if exists(':GitGutter')
GitGutter
endif
echo 'done!'
2021-01-02 18:15:08 +08:00
else
echo 'failed!'
2021-01-02 18:15:08 +08:00
endif
endfunction
2021-01-02 18:15:08 +08:00
function! git#reset#complete(ArgLead, CmdLine, CursorPos)
2021-01-02 18:15:08 +08:00
return "%\n" . join(getcompletion(a:ArgLead, 'file'), "\n")
endfunction
endif