spacevim/bundle/gina.vim/autoload/gina/command/_raw.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

114 lines
3.5 KiB
VimL

function! gina#command#_raw#call(range, args, mods) abort
let git = gina#core#get()
let args = s:build_args(git, a:args)
let pipe = a:mods =~# '\<silent\>'
\ ? deepcopy(s:pipe_silent)
\ : deepcopy(s:pipe)
return gina#process#open(git, args, pipe)
endfunction
function! gina#command#_raw#complete(arglead, cmdline, cursorpos) abort
let args = gina#core#args#new(matchstr(a:cmdline, '^.*\ze .*'))
if empty(args.get(1))
return gina#complete#common#raw_command(a:arglead, a:cmdline, a:cursorpos)
endif
if args.get(1) =~# '^\%(fetch\|pull\|push\|switch\)$'
return s:{args.get(1)}_complete(a:arglead, a:cmdline, a:cursorpos)
endif
return []
endfunction
" Private --------------------------------------------------------------------
function! s:build_args(git, args) abort
let args = a:args.clone()
if args.get(0) ==# '_raw'
" Remove leading '_raw' if exists
call args.pop(0)
endif
return args.lock()
endfunction
function! s:fetch_complete(arglead, cmdline, cursorpos) abort
let args = gina#core#args#new(matchstr(a:cmdline, '^.*\ze .*'))
if empty(args.get(2))
return gina#complete#common#remote(a:arglead, a:cmdline, a:cursorpos)
endif
if empty(args.get(3))
" TODO: Return refspecs in remote repository "args.get(2)".
endif
return []
endfunction
function! s:pull_complete(arglead, cmdline, cursorpos) abort
let args = gina#core#args#new(matchstr(a:cmdline, '^.*\ze .*'))
if empty(args.get(2))
return gina#complete#common#remote(a:arglead, a:cmdline, a:cursorpos)
endif
if empty(args.get(3))
" TODO: Return refspecs in remote repository "args.get(2)".
endif
return []
endfunction
function! s:push_complete(arglead, cmdline, cursorpos) abort
let args = gina#core#args#new(matchstr(a:cmdline, '^.*\ze .*'))
if empty(args.get(2))
return gina#complete#common#remote(a:arglead, a:cmdline, a:cursorpos)
endif
if empty(args.get(3))
return gina#complete#commit#local_branch(a:arglead, a:cmdline, a:cursorpos)
endif
return []
endfunction
function! s:switch_complete(arglead, cmdline, cursorpos) abort
let args = gina#core#args#new(matchstr(a:cmdline, '^.*\ze .*'))
if empty(args.get(2))
return gina#complete#commit#local_branch(a:arglead, a:cmdline, a:cursorpos)
endif
return []
endfunction
" Pipe -----------------------------------------------------------------------
function! s:_pipe_on_exit(exitval) abort dict
call call(s:original_pipe.on_exit, [a:exitval], self)
call gina#core#emitter#emit(
\ 'command:called:raw',
\ self.params.scheme,
\)
endfunction
function! s:_pipe_silent_on_exit(exitval) abort dict
call call(s:original_pipe_silent.on_exit, [a:exitval], self)
call gina#core#emitter#emit(
\ 'command:called:raw',
\ self.params.scheme,
\)
endfunction
let s:original_pipe = gina#process#pipe#echo()
let s:original_pipe_silent = gina#process#pipe#default()
let s:pipe = extend(deepcopy(s:original_pipe), {
\ 'on_exit': function('s:_pipe_on_exit'),
\})
let s:pipe_silent = extend(deepcopy(s:original_pipe_silent), {
\ 'on_exit': function('s:_pipe_silent_on_exit'),
\})
" Event ----------------------------------------------------------------------
function! s:on_command_called_raw(...) abort
call gina#core#emitter#emit('modified:delay')
endfunction
if !exists('s:subscribed')
let s:subscribed = 1
call gina#core#emitter#subscribe(
\ 'command:called:raw',
\ function('s:on_command_called_raw')
\)
endif