-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
vim very slow with semantic tokens enabled (with a possible fix) #4879
Comments
cridemichel
changed the title
vim very slow with semantic tokens enabled
vim very slow with semantic tokens enabled (with a possibile fix)
Feb 2, 2024
cridemichel
changed the title
vim very slow with semantic tokens enabled (with a possibile fix)
vim very slow with semantic tokens enabled (with a possible fix)
Feb 2, 2024
ALTERNATIVE FIXif one does not want to resort to vim9 scripting, list slicing can used and the function "s:add_highlights_timer" function! s:add_highlights_timer(bufnr, ns, highlights, priority) abort
let lhl = len(a:highlights)
let maxc = g:coc_highlight_maximum_count
if maxc < lhl
let hls = a:highlights[:maxc-1]
let next = a:highlights[maxc:]
else
let hls = a:highlights[:]
let next = []
endif
if bufwinnr(a:bufnr)!=-1 " check if buffer exists
call s:add_highlights(a:bufnr, a:ns, hls, a:priority)
endif
if len(next) && bufwinnr(a:bufnr)!=-1
call timer_start(g:coc_highlight_timer, {->s:add_highlights_timer(a:bufnr, a:ns, next, a:priority)})
endif
endfunction this solution is as efficient as the previous one and does not require vim9 scripting |
PR is welcome! |
thanks and please give a look at second fix in #4872 related to error E964, are you able to reproduce it? |
cridemichel
pushed a commit
to cridemichel/coc.nvim
that referenced
this issue
Feb 3, 2024
fannheyward
pushed a commit
that referenced
this issue
Feb 18, 2024
fannheyward
added a commit
that referenced
this issue
Feb 28, 2024
00bd79e fix(tests): fix broken tests on nightly (#4901) bb6df56 feat(completion): add g:coc_disable_mappings_check (#4913) 901226b fix(symbols): close outline preview at closing (#4911) 4807b2d fix(symbol): don't decrease end.line for Python (#4909) 3232964 fix(links): improve regex of link (#4906) 4bb274c fix(highlight): check buffer exist to highlight (#4874) 23e0566 feat(model): use getbufinfo to check command line (#4902) b14c1e9 chore(ci): npm run lint bbb3ec7 chore(package): update eslint related (#4900) c2c7132 chore(package): update jest related (#4898) 820a49f feat(completion): add suggest.chineseSegments (#4833) e44b117 fix(configuration): merge dotted config (#4895) dc633ad fix(codeLens): clear whole buffer on resolving (#4812) ae9ddb7 fix(handler): increase inlayHint render debounce (#4805) a716465 fix(core): disable cached-dir for resolving root (#4827) a2a3eea refactor(window): use nvim_get_option_value (#4769) 53ec5ad fix(native): checkComplete for file/buffer/around (#4794) d35f0d0 fix(dialog): set nonumber for floating doc (#4870) d49c6ee fix(ui): wrap the url in quotes to open (#4832) e18f99b fix(client): ignore -1 abnormal exit (#4868) ebc63cf fix(rpc): check coc_status exists before unlet (#4850) 610f5a4 fix(tests): incorrect comparing (#4839) 45f8a11 fix(configuration): join local coc-settings.json (#4854) 02c4a31 fix issues #4879 and #4872 (#4885) 9c079ad feat(diagnostic): add `DiagnosticWithFileType` (#4881) 392264f feat(list): support moving by word in prompt (#4867) ddf40ce feat(list): support <C-space> and <C-_> mappings (#4863) 3de02d7 chore(deps): bump follow-redirects from 1.15.2 to 1.15.4 (#4856) e42d5dc fix: block Vim until completion resolve finishes (#4847) 0006118 chore(docs): Fix typo curosr => cursor (#4848) da5201d chore(README): Update Node.JS version required. (#4849) 9831f9b fix: keep autocmds on registering new one (#4846) f82e420 fix: always pass `opts.close` for dialog (#4835) e108777 fix: floatFactory should not set `zindex: 1` (#4816) 9c3723a fix: CocTagFunc jumps to wrong position if using tabs for indentation (#4810) e3f91b5 chore(deps-dev): bump @babel/traverse from 7.22.11 to 7.23.2 (#4783)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result from CocInfo
VIM VERSION
coc json file
Describe the bug
If semantic tokens are enabled and a large file is opened,
vim is very slow, not to say unusuable, until adding highlights is over.
For example just after having opened a large file vim "stutters" a lot on scrolling
by pressing <PgUp> or <PgDown>.
In the following I propose also a possible way to fix this issue. If you find it more convenient,
I could create a pull request.
Reproduce the bug
> unzip files.zip
the command:
just after the file is opened start scrolling by pressing <PgDown>
vim "stutters" and it is generally slow (even if you try to move around with left/right arrows)
until adding highlights is over.
POSSIBLE FIX
After some debugging I found that the cause of this slowdown is due to
the for loop in function "s:add_highlights_timer", i.e
hence I decided to resort to vim9 scripting, which is supposed to be much faster.
What I suggest is to replace the function "s:add_highlights_timer", i.e.
with
Note that the patch suggested in #4872 has been already applied and a new function, called CreateHlLists(), has been added. This function is written in vim9 scripting language and it turned out to be insanely faster than the legacy solution.
file used to reproduce the bug
files.zip
Minimal vimrc file
Screenshots (optional)
before the fix:
stuttering.mp4
after the fix:
nostuttering.mp4
The text was updated successfully, but these errors were encountered: