wilder.nvim icon indicating copy to clipboard operation
wilder.nvim copied to clipboard

wilder.nvim is slow when using `Man` command to check executable docs

Open jdhao opened this issue 3 years ago • 1 comments

This is my config for wilder.nvim:

    call wilder#enable_cmdline_enter()
    set wildcharm=<Tab>
    cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
    cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"

    " only / and ? are enabled by default
    call wilder#set_option('modes', ['/', '?', ':'])

I am using Neovim 0.5.1. When openning nvim and run command Man and then type the name of a shell utility, e.g., ls, I have to wait several seconds for the autocompletion to show up.

How can we reduce lagging or slowness?

jdhao avatar Nov 20 '21 15:11 jdhao

This is due to the cmdline completion for Man (man#complete) taking a while (sometimes over 1 second) to get completions. Since it does so synchronously, Vim is blocked until the function returns.

A workaround is to add a check and don't complete for the Man command.

" Has to be added as the first branch.
call wilder#set_option('pipeline', [
      \ wilder#branch(
      \   [
      \     wilder#check({-> getcmdtype() ==# ':'}),
      \     {ctx, x -> wilder#cmdline#parse(x).cmd ==# 'Man' ? v:true : v:false},
      \   ],
      \  ... rest of the pipelines ...
      \ )])

Returning v:true tells wilder to be hidden so you can still use the default wildmenu.

I'll add this check by default so you won't have to add this in the future.

gelguy avatar Nov 20 '21 17:11 gelguy