Skip to content

Instantly share code, notes, and snippets.

@unclechu
Last active October 20, 2016 20:29
Show Gist options
  • Save unclechu/b6b181dd7e72b518fab5cfa0efcc0e2d to your computer and use it in GitHub Desktop.
Save unclechu/b6b181dd7e72b518fab5cfa0efcc0e2d to your computer and use it in GitHub Desktop.
Vim: Unite plugin: 'menu' source: Solution to merge all child elements from all groups to single group
let s:u_all = []
let s:u_max_prefix_length = 0
for [k, v] in items(g:unite_source_menu_menus)
if s:u_max_prefix_length < len(v.description)
let s:u_max_prefix_length = len(v.description)
endif
for item in v.command_candidates
call add(s:u_all, [v.description, item[0], item[1]])
endfor
endfor
let s:u_all_pfx = []
for item in s:u_all
let s:u_desc = item[0]
while len(s:u_desc) < s:u_max_prefix_length
let s:u_desc = s:u_desc . ' '
endwhile
call add(s:u_all_pfx, [s:u_desc . ' | ' . item[1], item[2]])
endfor
let g:unite_source_menu_menus.all = { 'description': 'All actions' }
let g:unite_source_menu_menus.all.command_candidates = s:u_all_pfx
unlet s:u_all
unlet s:u_all_pfx
unlet s:u_max_prefix_length
unlet s:u_desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment