Skip to content

Noticeable delay found between pressing a key and the key appears when using coc on GVim+Windows #5323

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

Open
skywind3000 opened this issue Apr 29, 2025 · 3 comments

Comments

@skywind3000
Copy link

Result from CocInfo

## versions

vim version: VIM - Vi IMproved 9.1 9011336
node version: v22.14.0
coc.nvim version: 0.0.82-317e12e 2025-04-22 23:46:55 +0800
coc.nvim directory: C:\Users\Linwei\.vim\bundles\coc.nvim
term: undefined
platform: win32

## Log of coc.nvim

2025-04-29T08:26:22.813 INFO (pid:32564) [extension:coc-git] - Looking for git in: git
2025-04-29T08:26:22.865 INFO (pid:32564) [plugin] - coc.nvim initialized with node: v22.14.0 after 407
2025-04-29T08:26:22.928 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:27.162 INFO (pid:32564) [services] - LanguageClient clangd state change: stopped => starting
2025-04-29T08:26:27.168 INFO (pid:32564) [language-client-index] - Language server "languageserver.clangd" started with 36740
2025-04-29T08:26:27.241 INFO (pid:32564) [services] - LanguageClient clangd state change: starting => running
2025-04-29T08:26:27.245 INFO (pid:32564) [services] - service languageserver.clangd started
2025-04-29T08:26:27.916 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:29.282 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:30.439 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:30.930 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:31.280 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:36.225 INFO (pid:32564) [attach] - receive notification: highlight []
2025-04-29T08:26:39.423 INFO (pid:32564) [attach] - receive notification: showInfo []

Describe the bug

coc.nvim becomes laggy and unresponsive recently. when typing in the INSERT mode,
noticeable delay can be found between pressing a key and the key got displayed.

profiling result:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
   95   0.799562   0.004507  coc#api#Notify()
 3010   0.789035   0.010764  coc#api#Call_function()
   55   0.770976   0.007344  coc#pum#create()
   49   0.752534   0.011832  coc#float#create_float_win()
   49   0.410253   0.000882  <SNR>271_add_highlights()
   49   0.409371   0.086863  coc#highlight#add_highlights()
   49   0.320396             coc#float#create_buf()
 9984   0.320359   0.156573  coc#highlight#add_highlight()
   28   0.151526             <lambda>5598()
   25   0.151499   0.000101  <lambda>5599()
 9984   0.116513   0.011247  coc#api#Buf_add_highlight()
 9984   0.101115   0.022556  coc#api#Buf_add_highlight1()
    2   0.084548   0.000096  ale#Queue()
    2   0.084259   0.000143  <SNR>246_Lint()
    2   0.083343   0.000045  ale#engine#RunLinters()
    2   0.083235   0.000104  <SNR>368_GetLintFileValues()
    2   0.083084   0.000125  <SNR>368_RunLinters()
    4   0.082641   0.000061  <SNR>368_RunLinter()
  678   0.080753   0.016497  Vim_NeatTabLabel()
 9984   0.071350             coc#api#CreateType()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
   49              0.320396  coc#float#create_buf()
 9984   0.320359   0.156573  coc#highlight#add_highlight()
   28              0.151526  <lambda>5598()
   49   0.409371   0.086863  coc#highlight#add_highlights()
 9984              0.071350  coc#api#CreateType()
  678              0.064256  Vim_NeatBuffer()
    8   0.042161   0.042022  ale#engine#IsExecutable()
10033   0.048736   0.040614  coc#compat#call()
 9984   0.101115   0.022556  coc#api#Buf_add_highlight1()
   39              0.020578  <SNR>266_BufferText()
    1   0.017439   0.017373  <SNR>260_request()
  678   0.080753   0.016497  Vim_NeatTabLabel()
    7   0.018242   0.016216  sy#repo#get_diff()
    4   0.015566   0.015497  ale#job#Start()
    2   0.016403   0.015349  <SNR>281_get_matching_delims()
    5   0.016480   0.014493  <SNR>259_Call()
  353   0.014963   0.014224  <SNR>260_notify()
   57   0.018403   0.011851  <SNR>281_get_delim()
   49   0.752534   0.011832  coc#float#create_float_win()
 9984   0.116513   0.011247  coc#api#Buf_add_highlight()

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't
reproduce it

  • Create file mini.vim with:
set nocompatible
set runtimepath^=D:/vim/plugins/coc.nvim
filetype plugin indent on
syntax on
set hidden

set updatetime=300
set signcolumn=yes

let g:coc_config_home = expand('~/.vim')

if !isdirectory(g:coc_config_home)
	silent! call mkdir(g:coc_config_home)
endif

inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1) :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? coc#pum#prev(1) : "\<C-h>"

function! s:check_back_space() abort
	let col = col('.') - 1
	return !col || getline('.')[col - 1]  =~# '\s'
endfunction

if has('nvim')
	inoremap <silent><expr> <c-space> coc#refresh()
else
	inoremap <silent><expr> <c-@> coc#refresh()
endif

nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

autocmd CursorHold * silent call CocActionAsync('highlight')

nmap <leader>rn <Plug>(coc-rename)
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

augroup MyCoCEventGroup
	autocmd!
	autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
	autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>ac  <Plug>(coc-codeaction)
nmap <leader>qf  <Plug>(coc-fix-current)
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)

nmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call     CocAction('fold', <f-args>)
command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
nnoremap <silent> <space>a  :<C-u>CocList diagnostics<cr>
nnoremap <silent> <space>e  :<C-u>CocList extensions<cr>
nnoremap <silent> <space>c  :<C-u>CocList commands<cr>
nnoremap <silent> <space>o  :<C-u>CocList outline<cr>
nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
nnoremap <silent> <space>j  :<C-u>CocNext<CR>
nnoremap <silent> <space>k  :<C-u>CocPrev<CR>
nnoremap <silent> <space>p  :<C-u>CocListResume<CR>

let g:coc_snippet_next = '<tab>'
imap <m-l> <Plug>(coc-snippets-expand)
vmap <m-j> <Plug>(coc-snippets-select)
let g:coc_snippet_next = '<m-j>'
let g:coc_snippet_prev = '<m-k>'
let g:coc_snippet_next = '<tab>'
  • Start (neo)vim with command: vim -u mini.vim

  • Operate vim.

Screenshots (optional)

Image

@fannheyward
Copy link
Member

coc.nvim version: 0.0.82-317e12e 2025-04-22 23:46:55 +0800

Upgrade to latest release, chemzqm were working on performance improvements on Vim9 this month.

Have you enabled semanticTokens.enable? Clangd server will produce lots of tokens to highlight, disable the semanticTokens highlighting, or increase g:coc_highlight_maximum_count and try again.

@chemzqm
Copy link
Member

chemzqm commented Apr 29, 2025

Seems caused by too many highlights with coc#highlight#add_highlights, can you test if using configuration "suggest.enableFloat": false or "suggest.autoTrigger": "none" helps?

@skywind3000
Copy link
Author

Will try when I come back from my holidays, right now I haven't got my laptop with me.

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

No branches or pull requests

3 participants