ZyX_I avatar 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
Untested

Comments (0)

Files changed (2)

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'
     else
         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.'.a:cmd.id.'.sp], ')).
                     \        '{}).curargs]'
+    else
+        let args='a:000'
     endif
     execute      'function '.a:fname."(...)\n"
                 \'    return call(s:commands.'.a:cmd.id.'.fs.'.a:fname[2:].', '.
     return a:copts[key]
 endfunction
 "▲3
-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
     endif
     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:plugdict.id, a:cid, a:copts, '')
     let cmd.rsp=s:F.getspfunc(a:plugdict.id, 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)
                 else
                     call s:_f.throw('ucomp', a:cid, a:plugdict.id)
                 endif
-            "▶4 Other options
+            "▶4 Command -* options
             else
                 unlet value
                 let value=a:copts[key]
                      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):
 @/functions:
     0.1: Added ability to have [{plid}, {version}, {key}] in 
          |frawor-fd-function| and |frawor-fd-thisplugin|.
+@/commands:
+    0.1: Added usecompsp option
 
 vim: ft=help:tw=78
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.