1. Ian Liu Rodrigues
  2. Vim Hg2O

Commits

Ian Liu Rodrigues  committed a48feb6

Add completion for Hg command

  • Participants
  • Parent commits bf79ca8
  • Branches default

Comments (0)

Files changed (1)

File hg2o.vim

View file
 " Maintainer:  Ian Liu Rodrigues
 " Version:     0.1
 
-if exists('g:loaded_hg2o') || &cp
-  finish
-endif
+"if exists('g:loaded_hg2o') || &cp
+"  finish
+"endif
 let g:loaded_hg2o = 1
 
 let s:HG = 'hg'
 endf
 
 " Returns the root dir of current buffer's HG repo
-fun! s:root()
+fun! s:root() abort
   if exists('b:hg_root') && b:hg_root !=# ''
     return b:hg_root
   endif
   call s:throw('not a mercurial repository: ' . expand('%:p'))
 endf
 
-com! -buffer -nargs=? Hg :execute s:Hg(<q-args>)
+com! -buffer -nargs=? -complete=customlist,s:HgComplete Hg :execute s:Hg(<q-args>)
 
 fun! s:Hg(cmd) abort
   exe '!' . s:HG . ' ' . a:cmd
 endf
 
-fun! s:HgComplete()
-  return '!HGPLAINEXCEPT=alias HGPLAIN=1 hg debugcomplete'
+fun! s:HgComplete(A, L, P) abort
+  let items = system(s:HG . ' debugcomplete '. a:A)
+  if v:shell_error == 0
+    return split(items, '\n')
+  endif
 endf