hrsh7th / nvim-cmp

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

Slow documentation window #1088

Open toto1384 opened 2 years ago

toto1384 commented 2 years ago

FAQ

Announcement

Minimal reproducible full config

Description

First of all. Great job on the plugin; it works well and fast.

One thing though that is slow is the documentation window. It works slowly both on my config and on configs like LunarVim. Sometimes I have to wait more than 3 seconds for it to show. And sometimes it works instantaneously. And it doesn't seem to matter how much data the documentation window is going to load

(The example below is not that bad, but sometimes it gets much slower)

Screen_Recording_2022-07-24_at_08_13_08_AdobeExpress

Steps to reproduce

Use it with a large typescript project

Expected behavior

Show it in 1 second max, not 3

Actual behavior

It is slow for large typescript projects. Even though shift+k works instantaneously

Additional context

No response

zolrath commented 1 year ago

I have a similar issue with a Rust project.

If I cargo add env_logger any completion beginning with e will lag for a couple of seconds as it takes a very long time to load the documentation window for env_logger. It completely freezes nvim while it loads the documentation.

I'd hope to see this load hiccup removed/the result cached so it only happens once but I'd also expect to be able to smoothly type the next letter without any hiccups. Seems odd that the documentation load is blocking the rest of the UI thread.

folke commented 1 year ago

Are you using Noice by any chance? I noticed a similar problem and turned out it was caused by displaying snippets. A snippet typically has dollar signs in them, that are incorrectly identified as latex by the markdown parser.

There was an issue with the noice highlighter where I didn't cache the highlight query, which means that after every garbage collect (every 2 seconds roughly), the full latex query had to be reloaded. Which is terribly slow.

I pushed a fix for this to noice yesterday, so only the very first invocation would be slower.

You could also just uninstall the latex treesitter parser.

The same issue might have causes slow-downs for other treesitter grammars as well.

AlxHnr commented 11 months ago

Are you using Noice by any chance? [...] caused by displaying snippets [...] ... You could also just uninstall the latex treesitter parser.

I have the same issue and use neither noice nor treesitter. I have not tested this with snippets, but it happens with clangd and zls too. The problem here is not that the docs take a while to load. The problem is that nvim is completely frozen for the few seconds the docs are loading.

For those who have found this discussion and want a workaround (from the docs):

local cmp = require('cmp')
cmp.setup{
  window = { documentation = cmp.config.disable },
  ... your other stuff here ...