hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.88k stars 394 forks source link

Speed / lag is hard to troubleshoot ? #1819

Open MarcWeber opened 7 months ago

MarcWeber commented 7 months ago

FAQ

Announcement

Minimal reproducible full config

I have a project eg using cmp-buf the longer I use vim the slower it gets. Also using intelliphense and some more. https://www.reddit.com/r/neovim/comments/ptlf4f/cocnvim_vs_nvimcmp_completion_response_speed/ describes that UI thread etc is being used etc.

But the main point is: How to find out without having to restart Vim many times what is causing the lag ? Cause then fixing it might be simple ?

Can't you just enable or provide a benchmark option?

:lua print(vim.inspect(require "cmp".last_stats))

which output gathering times of completions and sorting times etc ?

Another cool feature would be knowing that a completion 'starts lagging' just disable it ? If you really need it you can still ctrl-space and get it back / included ?

The cmp output could be like { cmp-buffer: 2000 items, 20ms intellphenes, 500 items, 50ms sorting: 500ms }

and you know what the problem actually is.

Sry the most simple thing is

ctrl-space -> all -> if one is slow, disable ctlr-space -> second time -> include all (it' sok to wait if I know what I wait for).

I tried different mappings for sources but somehow cursor started jumping I didn't debug yet.

I can restart my Vim once a hour .. but it kinda disrupts.

Description

The more buffers I have the slower it gets

Steps to reproduce

not important

Expected behavior

There should be a simple way to benchmark and identify the problem and that should be documented.

Actual behavior

searching for speed / benchmark etc in docs doesn't find anything. Also tried FAQ

It's not bad to be slow. But its bad if its hard to trouble shoot.

Additional context

.

Shougo commented 7 months ago

It may help you.

                                        *cmp-config.performance.fetching_timeout*
performance.fetching_timeout~
    `number`
    Sets the timeout of candidate fetching process.
    The nvim-cmp will wait to display the most prioritized source.
ibash commented 5 months ago

Thanks @Shougo!