vim-lsp icon indicating copy to clipboard operation
vim-lsp copied to clipboard

export lsp#omni#filter

Open mattn opened this issue 2 years ago • 2 comments

This can be used for filtering items in asyncomplete-lsp.

diff --git a/plugin/asyncomplete-lsp.vim b/plugin/asyncomplete-lsp.vim
index bc42d3d..9193dc7 100644
--- a/plugin/asyncomplete-lsp.vim
+++ b/plugin/asyncomplete-lsp.vim
@@ -99,5 +99,8 @@ function! s:handle_completion(server, position, opt, ctx, data) abort
     let l:startcol = l:col - l:kwlen
     let l:startcol = min([l:startcol, get(l:completion_result, 'startcol', l:startcol)])
 
+    let l:filter = has_key(a:server, 'config') && has_key(a:server['config'], 'filter') ? a:server['config']['filter'] : { 'name': 'prefix' }
+    let l:completion_result['items'] = lsp#omni#filter(l:filter['name'], l:completion_result['items'], l:kw)
+
     call asyncomplete#complete(a:opt['name'], a:ctx, l:startcol, l:completion_result['items'], l:completion_result['incomplete'])
 endfunction

However, this change causes asyncomplete-lsp to behave more like a prefix filter than like a contains filter. What do you think? @prabirshrestha

mattn avatar Jul 04 '22 00:07 mattn

Was in a vacation and seem to have missed this notification.

Looks good to me though I would also like to see support for fuzzy that uses matchfuzzy if it exists and potentially make this the default instead?

Since it is a public function we should document it.

prabirshrestha avatar Jul 22 '22 17:07 prabirshrestha

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 20 '22 23:09 stale[bot]