1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 20:30:05 +08:00

Add Git rm command (#4347)

This commit is contained in:
Wang Shidong 2021-08-01 13:30:23 +08:00 committed by GitHub
parent e6cb9e9003
commit 697fec62ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 14 deletions

1
.gitignore vendored
View File

@ -39,3 +39,4 @@ jdt.ls-java-project/
# generated by rustfmt.vim
# https://github.com/rust-lang/rust.vim/blob/master/autoload/rustfmt.vim#L110
view/
.vim-bookmarks

View File

@ -1,16 +1,13 @@
## Forked repos
## Bundle plugins
In `bundle/` directory, there are two kinds of plugins: forked plugins without changes and forked plugins which have been changed.
### Changed plugin:
- `vim-bookmarks`: based on [`MattesGroeger/vim-bookmarks@3adeae1`](https://github.com/MattesGroeger/vim-bookmarks/commit/3adeae10639edcba29ea80dafa1c58cf545cb80e)
### No changed plugins
- [defx.nvim](https://github.com/Shougo/defx.nvim/tree/df5e6ea6734dc002919ea41786668069fa0b497d)
- [dein.vim](https://github.com/Shougo/dein.vim/tree/772ae08cef5e712b2b31b4aaee908fc853accd94)
- [neoformat](https://github.com/sbdchd/neoformat/tree/1a49552cdaddeaaa766a6f0016effe530634b39f)
### checkers layer
- neomake
- vim-snippets
- neco-syntax
- context_filetype.vim
- neoinclude.vim
- neosnippet-snippets
- neopairs.vim

View File

@ -29,6 +29,8 @@ function! git#run(...) abort
call git#config#run(a:000[1:])
elseif cmd ==# 'diff'
call git#diff#run(a:000[1:])
elseif cmd ==# 'rm'
call git#rm#run(a:000[1:])
elseif cmd ==# 'log'
call git#log#run(a:000[1:])
elseif cmd ==# 'reflog'
@ -72,11 +74,13 @@ 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',
\ 'blame', 'pull', 'stash', 'cherry-pick', 'rm'
\ ],
\ "\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\+push\s\+.*$'
return git#push#complete(a:ArgLead, a:CmdLine, a:CursorPos)
elseif str =~# '^Git\s\+diff\s\+.*$'

View File

@ -0,0 +1,44 @@
""
" @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 %
" <
let s:JOB = SpaceVim#api#import('job')
function! git#rm#run(files) abort
if len(a:files) == 1 && a:files[0] ==# '%'
let cmd = ['git', 'rm', expand('%')]
else
let cmd = ['git', 'rm'] + a:files
endif
call git#logger#info('git-rm 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-rm 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

View File

@ -7,7 +7,8 @@ CONTENTS *git-contents*
2. Commands...................................................|git-commands|
1. git-add.....................................................|git-add|
2. git-cherry-pick.....................................|git-cherry-pick|
3. git-stash.................................................|git-stash|
3. git-rm.......................................................|git-rm|
4. git-stash.................................................|git-stash|
==============================================================================
INTRODUCTION *git-intro*
@ -38,6 +39,15 @@ This command is to cherry pick commit from other branch.
:Git cherry-pick <HashA> <HashB>
<
==============================================================================
GIT-RM *git-rm*
This commands is to rm file contents to the index. For example, rm current
file to the index.
>
:Git rm %
<
==============================================================================
GIT-STASH *git-stash*