Commits

Ingo Karkat committed 964612a

ENH: Allow to pass [item, menu] in callbackitem-mode.

For custom items, there often is additional information available. Let's slightly extend the fuf#callbackitem#launch() interface to also take a [item, menutext] tuple instead of a simple string.

  • Participants
  • Parent commits 4014e50
  • Branches enh-callbackitem-with-menu

Comments (0)

Files changed (2)

File autoload/fuf/callbackitem.vim

   let s:forPath = a:forPath
   let s:items = copy(a:items)
   if s:forPath
-    call map(s:items, 'fuf#makePathItem(v:val, "", 1)')
+    call map(s:items, 'call("fuf#makePathItem", s:makeItem(v:val) + [1])')
     call fuf#mapToSetSerialIndex(s:items, 1)
     call fuf#mapToSetAbbrWithSnippedWordAsPath(s:items)
   else
-    call map(s:items, 'fuf#makeNonPathItem(v:val, "")')
+    call map(s:items, 'call("fuf#makeNonPathItem", s:makeItem(v:val))')
     call fuf#mapToSetSerialIndex(s:items, 1)
     call map(s:items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
   endif
 
 let s:MODE_NAME = expand('<sfile>:t:r')
 
+function s:makeItem(item)
+  return (type(a:item) == type([]) ? a:item : [a:item, ''])
+endfunction
+
 " }}}1
 "=============================================================================
 " s:handler {{{1
                           arguments which are a name of selected item and a
                           number of open method when completed.
                           listener.onAbort() is called when aborted.
-        items           - List of items.
+        items           - List of items; either a string or [item, menutext].
         forPath         - If non-zero, use a matching method for files.
 
 Example of use: