Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Git rm command #4347

Merged
merged 9 commits into from Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -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
21 changes: 9 additions & 12 deletions bundle/README.md
@@ -1,16 +1,13 @@
## Forked repos
## Bundle 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)
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)

### checkers layer
### No changed plugins

- neomake
- vim-snippets
- neco-syntax
- context_filetype.vim
- neoinclude.vim
- neosnippet-snippets
- neopairs.vim
- [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)
6 changes: 5 additions & 1 deletion bundle/git.vim/autoload/git.vim
Expand Up @@ -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'
Expand Down Expand Up @@ -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\+.*$'
Expand Down
44 changes: 44 additions & 0 deletions bundle/git.vim/autoload/git/rm.vim
@@ -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
12 changes: 11 additions & 1 deletion bundle/git.vim/doc/git.txt
Expand Up @@ -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*
Expand Down Expand Up @@ -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*

Expand Down