ZyX_I  committed d1f2747

@/commands: Made it use splitfunc for dictionary functions as well. For
backwards compatibility this behavior is only used when new
“usedictcompsplitfunc” is present and true

  • Participants
  • Parent commits 6bd4f81

Comments (0)

Files changed (2)

File autoload/frawor/commands.vim

 "▶1 Header
 scriptencoding utf-8
-execute frawor#Setup('0.0', {'@/autocommands': '0.0',
+execute frawor#Setup('0.1', {'@/autocommands': '0.0',
             \                         '@/fwc': '0.0',})
 "▶1 Define messages
 if v:lang=~?'ru'
 function s:F.wrapfunc(cmd, fname, fdescr)
     if type(a:fdescr)==type({})
         let a:cmd.fs[a:fname[2:]]=call(a:cmd.wrapfunc, [a:fdescr], {})
-        let args='a:000'
         let lcomp=len(a:fdescr)
         if lcomp==1
         unlet a:cmd.g
         let [a:cmd.fs[a:fname[2:]], a:cmd.FWCid]=
                     \call(s:_f.fwc.compile, compargs, {})
+    endif
+    if a:cmd.usedictcompsplitfunc
         let args     = '[call(s:F.splitfunc, '.
                     \        'a:000'.
                     \        ((a:cmd.sp is 0)?
                     \           (', '):
                     \           ('+[s:commands.''.sp], ')).
                     \        '{}).curargs]'
+    else
+        let args='a:000'
     execute      'function '.a:fname."(...)\n"
                 \'    return call(s:commands.''.fs.'.a:fname[2:].', '.
     return a:copts[key]
-let s:cmddefaults={
+let s:cmddefaults=sort(items({
             \   'nargs': '0',
             \'complete':  0,
             \   'range':  0,
             \     'bar':  1,
             \'register':  0,
             \  'buffer':  0,
-        \}
+        \}))
 let s:compaugprefix='LoadCompFunc_'
 function s:F.command.add(plugdict, fdict, cid, cstr, copts)
     "▶3 Checking arguments
     let cmdstring=''
     let addargs=[]
+    let cmd.usedictcompsplitfunc=get(a:copts, 'usedictcompsplitfunc',
+                \             type(get(a:copts, 'complete'))==type([]))
     "▶3 Process *splitfunc
     let cmd.sp=s:F.getspfunc(, a:cid, a:copts, '')
     let cmd.rsp=s:F.getspfunc(, a:cid, a:copts, 'r')
     "▶3 Create :command -options
-    for [key, value] in sort(items(s:cmddefaults))
+    for [key, value] in s:cmddefaults
         if a:plugdict.isftplugin && key is# 'buffer'
             let value=1
         elseif has_key(a:copts, key)
                     call s:_f.throw('ucomp', a:cid,
-            "▶4 Other options
+            "▶4 Command -* options
                 unlet value
                 let value=a:copts[key]

File doc/frawor.txt

                      done only after plugin is loaded.
         splitfunc, rsplitfunc
                   Defines function that will split command-line into a list of 
-                  arguments. `splitfunc' is for FWC completion, `rsplitfunc' 
-                  is for running. Latter is valid only if {cstr} is not 
-                  a string. Use 0 to keep default behavior.
+                  arguments. `splitfunc' is for completion (only valid if 
+                  completion defined by a list), `rsplitfunc' is for running 
+                  (valid only if {cstr} is not a string). You may use 0 to 
+                  keep default behavior.
+        usedictcompsplitfunc
+                  If true, makes `splitfunc' key be also used for dictionary 
+                  completion definitions.
         Order of additional arguments if any (only applicable if {cstr} is 
         a dictionary or a function reference):
     0.1: Added ability to have [{plid}, {version}, {key}] in 
          |frawor-fd-function| and |frawor-fd-thisplugin|.
+    0.1: Added usecompsp option
 vim: ft=help:tw=78