Source

aurum / autoload / aurum / cmdutils.vim

Diff from to

autoload/aurum/cmdutils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('4.2', {'@/resources': '0.0',
+execute frawor#Setup('4.3', {'@/resources': '0.0',
             \                       '@/os': '0.0',
             \               '@%aurum/repo': '5.0',
             \               '@%aurum/edit': '1.0',
     endwhile
     return r
 endfunction
+"▶1 completion-related constants
+let s:r.comp={}
+let s:r.comp.rev    = 'type string'
+let s:r.comp.file   = 'type String'
+let s:r.comp.cmd    = 'type STRING'
+let s:r.comp.optrev = 'type STRing'
+let s:r.comp.repo   = ':":"(either(path d, match@\v^\w+%(\+\w+)*\V://\v|^\:$@))'
+let s:r.compcmds=['new', 'vnew', 'edit',
+            \     'leftabove\ vnew', 'rightbelow\ vnew',
+            \     'topleft\ vnew',   'botright\ vnew',
+            \     'aboveleft\ new',  'belowright\ new',
+            \     'topleft\ new',    'botright\ new',]
+" XXX Some code relies on the fact that all options from s:diffoptslst are
+"     numeric
+let s:r.diffopts=['git', 'reverse', 'ignorews', 'iwsamount', 'iblanks',
+            \     'numlines', 'showfunc', 'alltext', 'dates']
+let s:r.comp.diffopts=join(map(copy(s:r.diffopts),
+            \          'v:val is# "numlines" ? '.
+            \               '" ?".v:val." range 0 inf" : '.
+            \               '"!?".v:val'))
+"▶1 Completion functions
+function s:r.revlist(...)
+    let repo=aurum#repository()
+    return       repo.functions.getrepoprop(repo, 'tagslist')+
+                \repo.functions.getrepoprop(repo, 'brancheslist')+
+                \repo.functions.getrepoprop(repo, 'bookmarkslist')
+endfunction
+"▶1 gencompfunc
+let s:replaces=[
+            \['\V'.s:r.comp.rev,     'in *_r.cmdutils.revlist', 'g'],
+            \['\V'.s:r.comp.file,    '(path)',                  'g'],
+            \['\V'.s:r.comp.cmd,     'first(in _r.cmdutils.compcmds, idof cmd)',
+            \                                                   'g'],
+            \['\V'.s:r.comp.optrev,  'either(type "", in *_r.cmdutils.revlist)',
+            \                                                   'g'],
+            \]
+function s:r.gencompfunc(fwc, subs, Compile)
+    let subs=a:subs+s:replaces
+    let fwc=substitute(a:fwc, '^-onlystrings\( _\)*', '', '')
+    for args in subs
+        let fwc=call('substitute', [fwc]+args)
+    endfor
+    return {'function': call(a:Compile, [fwc, 'complete'], {})[0]}
+endfunction
 "▶1 Post cmdutils resource
 call s:_f.postresource('cmdutils', s:r)
 "▶1