Ian Liu Rodrigues avatar Ian Liu Rodrigues committed a48feb6

Add completion for Hg command

Comments (0)

Files changed (1)

 " 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.