Permalink
Browse files

Merge branch 'feature/enable-on-neovim/devel'

  • Loading branch information...
2 parents 2fbafb8 + 954afea commit 723c0a0b25b359abb8d0e6cc65154f44c9ce0e11 @kmnk committed Nov 15, 2016
Showing with 62 additions and 6 deletions.
  1. +35 −0 autoload/giti.vim
  2. +13 −2 autoload/giti/commit.vim
  3. +14 −4 autoload/giti/rebase.vim
View
@@ -70,6 +70,41 @@ function! giti#system_with_specifics(param) "{{{
endif
endfunction "}}}
+function! giti#termopen_with_specifics(param) "{{{
+ if !has('nvim')
+ echoerr 'termopen is not supported'
+ endif
+
+ if !giti#is_git_repository()
+ call giti#print('Not a git repository')
+ call giti#print('Specify directory of git repository (and change current directory of this window)')
+ call giti#print('current : ' . getcwd())
+ let new_directory = giti#input('change to: ', getcwd())
+ if new_directory == ''
+ " Note 'redraw' is required to prevent 'Press ENTER or type...' message
+ redraw | call giti#print('cacneled')
+ return
+ endif
+ call giti#execute(printf('lcd %s', new_directory))
+ return giti#terminal_with_specifics(a:param)
+ endif
+
+ let a:param.command = s:normalize_command(a:param.command)
+
+ if exists('a:param.with_confirm') && a:param.with_confirm
+ if !giti#is_confirmed(a:param.command)
+ call giti#print('canceled')
+ return
+ endif
+ endif
+
+ let ret = termopen(g:giti_git_command . ' ' . a:param.command)
+
+ if exists('a:param.startinsert') && a:param.startinsert
+ startinsert
+ endif
+endfunction "}}}
+
function! giti#dir() "{{{
if !exists('b:giti_dir')
let b:giti_dir = giti#system('rev-parse --git-dir')
View
@@ -23,8 +23,19 @@ endfunction "}}}
" local functions {{{
function! s:run(command, files) "{{{
- call s:make_commit_editmsg(a:command, a:files)
- call s:edit_commit_editmsg(a:command, a:files)
+ if has('nvim')
+ call s:commit(a:command, a:files)
+ else
+ call s:make_commit_editmsg(a:command, a:files)
+ call s:edit_commit_editmsg(a:command, a:files)
+ endif
+endfunction "}}}
+
+function! s:commit(command, files) "{{{
+ call giti#termopen_with_specifics({
+\ 'command' : a:command . ' -- ' . join(a:files),
+\ 'startinsert' : 1,
+\ })
endfunction "}}}
function! s:make_commit_editmsg(command, files) "{{{
View
@@ -24,10 +24,20 @@ function! giti#rebase#run(param) "{{{
endfunction "}}}
function! giti#rebase#interactive(param) "{{{
- return giti#execute(printf('! git rebase -i %s %s',
-\ has_key(a:param, 'onto') ? '--onto ' . a:param.onto : '',
-\ has_key(a:param, 'upstream') ? a:param.upstream : '',
-\ ))
+ if has('nvim')
+ return giti#termopen_with_specifics({
+\ 'command' : printf('rebase -i %s %s',
+\ has_key(a:param, 'onto') ? '--onto ' . a:param.onto : '',
+\ has_key(a:param, 'upstream') ? a:param.upstream : '',
+\ ),
+\ 'startinsert' : 1,
+\ })
+ else
+ return giti#execute(printf('! git rebase -i %s %s',
+\ has_key(a:param, 'onto') ? '--onto ' . a:param.onto : '',
+\ has_key(a:param, 'upstream') ? a:param.upstream : '',
+\ ))
+ endif
endfunction "}}}
function! giti#rebase#continue() "{{{

0 comments on commit 723c0a0

Please sign in to comment.