Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Highlighting gets slow as files grow in size #63

Open
MysteriousJ opened this issue May 8, 2021 · 2 comments
Open

Highlighting gets slow as files grow in size #63

MysteriousJ opened this issue May 8, 2021 · 2 comments

Comments

@MysteriousJ
Copy link

Highlighting is perfectly fast on small files, but once files get over 500 lines, highlighting noticeably lags for every few characters I type in insert mode. It would be great if there was a way to disable highlighting while typing, or only reapply highlighting on a function call so it could be hooked up to an autocmd.

Configuration:

  • Neovim 0.5.0
  • CoC 0.0.74 with clangd version 11.0.1

CoC configuration:

{
	"clangd.semanticHighlighting": true,
	"coc.preferences.hoverTarget": "echo",
	"emitInactiveRegions" : true,
	"diagnostic.enable": false
}

Log from typing in a 1400 line file:

5/7/2021 8:10:11 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:11 PM: hl_symbols (textprop nvim) highlighted 3485 symbols in file src\Entity.h
5/7/2021 8:10:11 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.244072s to complete
5/7/2021 8:10:11 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:12 PM: hl_symbols (textprop nvim) highlighted 3485 symbols in file src\Entity.h
5/7/2021 8:10:12 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.244040s to complete
5/7/2021 8:10:12 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:12 PM: hl_symbols (textprop nvim) highlighted 3485 symbols in file src\Entity.h
5/7/2021 8:10:12 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.241240s to complete
5/7/2021 8:10:12 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:12 PM: hl_symbols (textprop nvim) highlighted 3380 symbols in file src\Entity.h
5/7/2021 8:10:12 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.225770s to complete
5/7/2021 8:10:12 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:12 PM: hl_symbols (textprop nvim) highlighted 3380 symbols in file src\Entity.h
5/7/2021 8:10:12 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.229005s to complete
5/7/2021 8:10:13 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:13 PM: hl_symbols (textprop nvim) highlighted 3380 symbols in file src\Entity.h
5/7/2021 8:10:13 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.236636s to complete
5/7/2021 8:10:13 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:13 PM: hl_symbols (textprop nvim) highlighted 3380 symbols in file src\Entity.h
5/7/2021 8:10:13 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.232892s to complete
5/7/2021 8:10:13 PM: textprop nvim notify symbols for src\Entity.h
5/7/2021 8:10:13 PM: hl_symbols (textprop nvim) highlighted 3380 symbols in file src\Entity.h
5/7/2021 8:10:13 PM: operation hl_symbols (textprop nvim) src\Entity.h took   0.225046s to complete

Log from typing in a 20 line file:

5/7/2021 8:13:12 PM: textprop nvim notify symbols for src\BuildConfig.h
5/7/2021 8:13:12 PM: hl_symbols (textprop nvim) highlighted 6 symbols in file src\BuildConfig.h
5/7/2021 8:13:12 PM: operation hl_symbols (textprop nvim) src\BuildConfig.h took   0.001372s to complete
5/7/2021 8:13:12 PM: textprop nvim notify symbols for src\BuildConfig.h
5/7/2021 8:13:12 PM: textprop nvim notify symbols for src\BuildConfig.h
5/7/2021 8:13:12 PM: stopped hl_symbols timer
5/7/2021 8:13:12 PM: hl_symbols (textprop nvim) highlighted 6 symbols in file src\BuildConfig.h
5/7/2021 8:13:12 PM: operation hl_symbols (textprop nvim) src\BuildConfig.h took   0.001457s to complete
5/7/2021 8:13:13 PM: textprop nvim notify symbols for src\BuildConfig.h
5/7/2021 8:13:13 PM: hl_symbols (textprop nvim) highlighted 6 symbols in file src\BuildConfig.h
5/7/2021 8:13:13 PM: operation hl_symbols (textprop nvim) src\BuildConfig.h took   0.001537s to complete
5/7/2021 8:13:13 PM: textprop nvim notify symbols for src\BuildConfig.h
5/7/2021 8:13:13 PM: hl_symbols (textprop nvim) highlighted 6 symbols in file src\BuildConfig.h
5/7/2021 8:13:13 PM: operation hl_symbols (textprop nvim) src\BuildConfig.h took   0.001419s to complete
@jackguo380
Copy link
Owner

Sorry for the late response, not sure if you're still experiencing this or have moved on. But anyways, that is sending a lot of requests. I personally don't use clangd so this slipped by me, the behvavior looks a lot worse.

I have made an initial attempt to address typing. We can't completely ignore updates to the highlighting during editing, but the timer period can be adjusted, if a new request comes in before the timer runs it will reset the timeout. This should result in dramatically fewer highlighting runs, obviously you won't get real-time highlight updates but that's probably fine.

The changes are on a separate branch as they are experimental: feature-mode-delay

These are new settings variables to toggle:

  • g:lsp_cxx_hl_delay - this is the default timer delay, usually 10ms. I don't recommend touching it unless the others aren't working well.
  • g:lsp_cxx_hl_use_mode_delay - bool, whether to vary the delay based on editor mode
  • g:lsp_cxx_hl_edit_delay_ms - edit mode (insert/replace) delay, defaults to 1000ms

Please try setting this and seeing if your situation improves:

let g:lsp_cxx_hl_use_mode_delay = 1
let g:lsp_cxx_hl_edit_delay_ms = 1000

You can play around with the edit delay to see if you prefer more or less latency.

@MysteriousJ
Copy link
Author

I've been using these settings for the past week and they work great! I prefer g:lsp_cxx_hl_delay_ms as it also makes successive normal mode operations smoother.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants