Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use faster highlighting when available #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aelkazdadi
Copy link

Using matchaddpos on each position individually has a lot of overhead, which causes vim to lag while it's highlighting too many targets. I've written two alternatives:

  • The first one builds a list of targets, then sends them to matchaddpos in batches of 8, which is the current limit.
  • The second one uses neovim api, which seems to be even more efficient.

I've compared the three methods on my machine using vim's profiler.
On a file with ~4k targets (61 lines, each containing 65 "aaa "s), the old method finishes highlights the targets in 4.3s, the batch method in 1.45s, and the neovim api in 1.05s.

  - Use matchaddpos with batches of 8 positions
  - Use nvim namespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant