Commits

ZyX_I committed 96a6a8f

@/commands: Fixed a typo, made command constructor ignore `nargs' option if `rsp' is not 0

Comments (0)

Files changed (2)

         Key      Description ~
         nargs     String or 0. Defines number of arguments, see 
                   |:command-nargs|. Use 0 to skip this argument. Default: "0".
+                  Ignored if `rsplitfunc' key is present and is not 0.
         range     0, 1, "%" or Number written as string. Defines default 
                   range, see |:command-range|. 1 means `add -range without 
                   argument'. Default: 0.
         splitfunc, rsplitfunc
                   Defines function that will split command-line into a list of 
                   arguments. `splitfunc' is for completion, `rsplitfunc' is 
-                  for running. Latter is valid only if {cstr} is not a string.
+                  for running. Latter is valid only if {cstr} is not a string. 
+                  Use 0 to keep default behavior.
 
 command.del : function( [ cid ] )                       *frawor-f-command.del*
         Delete command named {cid} if it was defined by this plugin. If no 

plugin/frawor/commands.vim

                 \'funs': [],
                 \}
     let cmdstring=''
+    "▶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 items(s:cmddefaults)
         if has_key(a:copts, key)
             endif
             "▲4
         endif
-        if value is 1
+        if key is# 'nargs' && cmd.rsp isnot 0
+            let cmdstring.='-nargs=1 '
+        elseif value is 1
             let cmdstring.='-'.key.' '
         elseif type(value)==type('')
             let cmdstring.='-'.key.'='.value.' '
         endif
         unlet value
     endfor
-    "▶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
     let cmdstring.=cmd.id.' '
     "▶3 Process replacement
         if cmd.rsp is 0
             let cmdstring.='[<f-args>]'
         elseif type(cmd.rsp)==type('')
-            let cmstring.='s:F.cmdsplit(<q-args>, s:commands.'.a:cid.'.rsp)'
+            let cmdstring.='s:F.cmdsplit(<q-args>, s:commands.'.a:cid.'.rsp)'
         else
             let cmdstring.='s:commands.'.a:cid.'.rsp(<q-args>)'
         endif