Enhancement: Align snippet names in unite source options
This commit is contained in:
parent
ef72df8e78
commit
1d4d8b0490
@ -31,15 +31,26 @@ function! s:unite_source.action_table.expand.func(candidate)
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:unite_source.longest_snippet(snippet_list)
|
||||||
|
let longest = 0
|
||||||
|
for snip in items(a:snippet_list)
|
||||||
|
if strlen(snip['word']) > longest
|
||||||
|
let longest = strlen(snip['word'])
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return longest
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:unite_source.gather_candidates(args, context)
|
function! s:unite_source.gather_candidates(args, context)
|
||||||
let default_val = {'word': '', 'unite__abbr': '', 'is_dummy': 0, 'source':
|
let default_val = {'word': '', 'unite__abbr': '', 'is_dummy': 0, 'source':
|
||||||
\ 'ultisnips', 'unite__is_marked': 0, 'kind': 'command', 'is_matched': 1,
|
\ 'ultisnips', 'unite__is_marked': 0, 'kind': 'command', 'is_matched': 1,
|
||||||
\ 'is_multiline': 0}
|
\ 'is_multiline': 0}
|
||||||
let snippet_list = UltiSnips#SnippetsInCurrentScope()
|
let snippet_list = UltiSnips#SnippetsInCurrentScope()
|
||||||
|
let max_len = s:unite_source.longest_snippet(snippet_list)
|
||||||
let canditates = []
|
let canditates = []
|
||||||
for snip in items(snippet_list)
|
for snip in items(snippet_list)
|
||||||
let curr_val = copy(default_val)
|
let curr_val = copy(default_val)
|
||||||
let curr_val['word'] = snip[0] . " " . snip[1]
|
let curr_val['word'] = printf('%-*s', max_len, snip[0]) . " " . snip[1]
|
||||||
let curr_val['trigger'] = snip[0]
|
let curr_val['trigger'] = snip[0]
|
||||||
call add(canditates, curr_val)
|
call add(canditates, curr_val)
|
||||||
endfor
|
endfor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user