asyncomplete-ezfilter.vim
asyncomplete-ezfilter.vim copied to clipboard
Sort by JW score?
I created a custom preprocess function for filtering and sorting by JW distance:
" sort by jw score provided by ezfilter
function! s:sort_by_jw(options, matches) abort
let l:items = []
for [l:source_name, l:matches] in items(a:matches)
for l:item in l:matches['items']
let l:item['jw'] =
\ asyncomplete#preprocessor#ezfilter#JaroWinkler#distance(l:item['word'], a:options['base'])
if l:item['jw'] <= 0.15
call add(l:items, l:item)
endif
endfor
endfor
let l:items = sort(l:items, {a, b -> a['jw'] == b['jw'] ? 0 : a['jw'] > b['jw'] ? 1 : -1})
call asyncomplete#preprocess_complete(a:options, l:items)
endfunction
let g:asyncomplete_preprocessor = [function('s:sort_by_jw')]
Wondered if there's any way to make this native to this plugin as a helper? Seems like it could be useful for other people (or could just be dropped into README).