hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
493 stars 42 forks source link

The plugin can block Neovim for a long time #85

Open gregorias opened 1 year ago

gregorias commented 1 year ago

This plugin synchronously calls vim.fn.getcompletion. When that happens, the entire Neovim is blocked until that call completes. Unfortunately, that call can take a long time in some circumstances. For example, completing :e huge_nfs_directory/ takes a minute on my machine. I suspect that https://github.com/hrsh7th/cmp-cmdline/issues/84 is another example of this.

There are a few avenues we could take to remedy this:

liquiddandruff commented 1 year ago

Hitting this too at the moment, made me think it was an issue with cmp-path: https://github.com/hrsh7th/cmp-path/issues/68

Temporarily working around this by disabling cmp-cmdline on e and edit:

  -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
        { name = 'path' },
        { name = 'cmdline', option = { ignore_cmds = { 'Man', '!', 'e', 'edit'}}}
    })
  })
girishji commented 11 months ago

It is possible to get around blocking calls that take a long time. I wrote a autocompletion plugin (https://github.com/girishji/autosuggest.vim) for cmdline-mode completion in vim9script. I solved this problem by adding a timeout to job_start(). There are certain completions that are long running (like ** expansion). I check them first in a separate process. I assume similar mechanism can be used in neovim as well.

miekg commented 5 months ago

hitting this too.

I would be happy (enough) with the ability to exclude some paths from cmp-path completion as a work-around (happy to file a feature request under cmp-path if desired)