Skip to content

Commit

Permalink
💥 Remove bang (!) and add ++wait to Gin command
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Aug 20, 2022
1 parent bb363e0 commit 5493be9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
16 changes: 8 additions & 8 deletions autoload/gin/internal/feat/branch/action.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endfunction

function! s:switch(xs) abort
let branch = a:xs[0]
execute printf('Gin! switch %s', branch.branch)
execute printf('Gin ++wait switch %s', branch.branch)
endfunction

function! s:new(suffix, xs) abort
Expand All @@ -48,7 +48,7 @@ function! s:new(suffix, xs) abort
echohl None
return
endif
execute printf('Gin! switch %s %s %s', a:suffix, name, from)
execute printf('Gin ++wait switch %s %s %s', a:suffix, name, from)
endfunction

function! s:new_orphan(xs) abort
Expand All @@ -60,7 +60,7 @@ function! s:new_orphan(xs) abort
echohl None
return
endif
execute printf('Gin! switch --orphan %s', name)
execute printf('Gin ++wait switch --orphan %s', name)
endfunction

function! s:move(force, xs) abort
Expand All @@ -74,7 +74,7 @@ function! s:move(force, xs) abort
return
endif
execute printf(
\ 'Gin! branch --move %s %s %s',
\ 'Gin ++wait branch --move %s %s %s',
\ a:force ? '--force' : '',
\ from,
\ name,
Expand All @@ -88,13 +88,13 @@ function! s:delete(force, xs) abort
endif
if branch.kind ==# 'remote'
execute printf(
\ 'Gin! push --delete %s %s',
\ 'Gin ++wait push --delete %s %s',
\ branch.remote,
\ branch.branch,
\)
else
execute printf(
\ 'Gin! branch %s %s',
\ 'Gin ++wait branch %s %s',
\ a:force ? '-D' : '-d',
\ branch.branch,
\)
Expand All @@ -108,7 +108,7 @@ function! s:merge(prefix, xs) abort
continue
endif
execute printf(
\ 'Gin! merge %s %s',
\ 'Gin ++wait merge %s %s',
\ a:prefix,
\ branch.target,
\)
Expand All @@ -121,7 +121,7 @@ function! s:rebase(prefix, xs) abort
continue
endif
execute printf(
\ 'Gin! rebase %s %s',
\ 'Gin ++wait rebase %s %s',
\ a:prefix,
\ branch.target,
\)
Expand Down
10 changes: 5 additions & 5 deletions autoload/gin/internal/feat/status/action.vim
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ endfunction

function! s:add(suffix, xs) abort
call s:norm_xs(a:xs)
execute printf('Gin! add --ignore-errors --force %s -- %s', a:suffix, join(a:xs, ' '))
execute printf('Gin ++wait add --ignore-errors --force %s -- %s', a:suffix, join(a:xs, ' '))
endfunction

function! s:rm(suffix, xs) abort
call s:norm_xs(a:xs)
execute printf('Gin! rm --quiet --ignore-unmatch --cached %s -- %s', a:suffix, join(a:xs, ' '))
execute printf('Gin ++wait rm --quiet --ignore-unmatch --cached %s -- %s', a:suffix, join(a:xs, ' '))
endfunction

function! s:reset(xs) abort
call s:norm_xs(a:xs)
execute printf('Gin! reset --quiet -- %s', join(a:xs, ' '))
execute printf('Gin ++wait reset --quiet -- %s', join(a:xs, ' '))
endfunction

function! s:restore(suffix, xs) abort
call s:norm_xs(a:xs)
execute printf('Gin! restore --quiet %s -- %s', a:suffix, join(a:xs, ' '))
execute printf('Gin ++wait restore --quiet %s -- %s', a:suffix, join(a:xs, ' '))
endfunction

function! s:stage(xs) abort
Expand Down Expand Up @@ -143,5 +143,5 @@ endfunction

function! s:stash(suffix, xs) abort
call s:norm_xs(a:xs)
execute printf('Gin! stash push --all %s -- %s', a:suffix, join(a:xs, ' '))
execute printf('Gin ++wait stash push --all %s -- %s', a:suffix, join(a:xs, ' '))
endfunction
4 changes: 2 additions & 2 deletions doc/gin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ INTERFACE *gin-interface*
COMMANDS *gin-commands*

*:Gin*
:Gin[!] [++{option}...] {command} [{args}]
:Gin [++{option}...] [++wait] {command} [{args}]
Call a git raw {command} with {args} asynchronously and echo result.
For example, "Gin add %" on "hello.txt" invokes "git add hello.txt".
If a bang (!) is specified, it calls command synchronously instead.
If ++wait is specified, it calls command synchronously instead.
See |gin-command-options| for available {option}s.
Use |:GinBuffer| to show the result in a buffer.

Expand Down
9 changes: 5 additions & 4 deletions plugin/gin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ augroup gin_plugin_internal
augroup END

function! s:command(bang, mods, args) abort
if a:bang ==# '!'
let args = filter(copy(a:args), { -> v:val !=# '++wait' })
if index(a:args, '++wait') isnot# -1
if denops#plugin#wait('gin')
return
endif
call denops#request('gin', 'command', [a:mods, a:args])
call denops#request('gin', 'command', [a:mods, args])
else
let l:Callback = function('denops#notify', [
\ 'gin',
\ 'command',
\ [a:mods, a:args],
\ [a:mods, args],
\])
call denops#plugin#wait_async('gin', l:Callback)
endif
endfunction

command! -bang -bar -nargs=* Gin call s:command(<q-bang>, <q-mods>, [<f-args>])
command! -bar -nargs=* Gin call s:command(<q-bang>, <q-mods>, [<f-args>])

function! s:buffer_command(...) abort
if denops#plugin#wait('gin')
Expand Down

0 comments on commit 5493be9

Please sign in to comment.