> ~ biozz / Blog

NeoVim Telescope Lag 2023-08-02

A short story of unexpected lags of the fastest tools.

Reading time: 1m (185 words)

Today I hit a sudden lag when using Live Grep in Telescope. You think this is impossible, but 5s spikes of 100% RAM and CPU usage on my M1 16G MacBook Air says otherwise.

I have ripgrep installed and I checked htop and it turned out, that lag comes from NeoVim and not from ripgrep. Also running rg from the command line is still very fast on the same query.

This happened only in one of my work projects. I started looking through the files and found that someone put 25Mb JSON file into the mock directory. I swear it was not me.

At first I thought it was related to nvim-treesitter and highlighting of the preview. But disabling treesitter didn’t help.

Adding mock to file_ignore_patterns was also a solution, but seemed to specific for this setting, because it usually has things like vendor or node_modules. Mock files in projects are not standardized.

Finally I decided to put .rgignore file into the project directory and also put .rgignore itself into my global .gitignore so I don’t accidentally commit it. Now Live Grep is fast again.