neoclide / coc-snippets

Snippets solution for coc.nvim
969 stars 41 forks source link

Error detected while processing function coc#pum#select_confirm... crashes nvim #354

Closed ben-wall closed 4 months ago

ben-wall commented 4 months ago
E31: No such mapping
Error detected while processing function coc#pum#select_confirm[6]..coc#pum#close[21]..coc#rpc#request[4]..<SNR>13_request[16]..coc#snippet#enable[6]..coc#snippet#_select_mappings:
line   13:

this error is in logs hundreds of times before then closes/crashes nvim.

:CocInfo

## versions

vim version: NVIM v0.10.0
node version: v20.15.0
coc.nvim version: 0.0.82-c3ae5c3b 2024-05-23 20:39:40 +0800
coc.nvim directory: /home/ben/.local/share/nvim/site/pack/packer/start/coc.nvim
term: xterm-kitty
platform: linux

## Log of coc.nvim

2024-06-22T18:25:39.420 INFO (pid:127995) [plugin] - coc.nvim initialized with node: v20.15.0 after 266
2024-06-22T18:25:39.427 WARN (pid:127995) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. 
    at t.initStatusBar (/home/ben/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:156009)
    at t.activate (/home/ben/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:23162)
2024-06-22T18:25:39.442 INFO (pid:127995) [language-client-index] - Language server "cSpell" started with 128011

opening vim with nvim -V3logfile -u ~/mini-init.vim src/app/app.component.html mini-init.vim:

set nocompatible
set runtimepath^=/home/ben/.local/share/nvim/site/pack/packer/start/coc.nvim
filetype plugin indent on
syntax on
set hidden

" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)

" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)

" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'

" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'

" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)

" Use <leader>x for convert visual selected code to snippet
xmap <leader>x  <Plug>(coc-convert-snippet)

inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#_select_confirm() :
      \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
      \ CheckBackspace() ? "\<TAB>" :
      \ coc#refresh()

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

let g:coc_snippet_next = '<tab>'

reproduce: create a

<div>
 </div>

and use snippets <div here> and navigate the list. Crashes every time.

ben-wall commented 4 months ago

crashed

It seems to only happen on non-custom snippets like div, span, h1 etc but anything custom from my html snippets (ultisnips) is fine

I've tried removing my snippets file entirely (html.snippts), it doesn't have any effect, still crashes

ben-wall commented 4 months ago

with -V20

line   13:
E31: No such mapping
line 14:   endfor
line 9:   for map in map(filter(split(mappings, '\n'), "v:val !~# '^s' && v:val !~# '^\\a*\\s*<\\S\\+>'"), "matchstr(v:val, '^\\a*\\s*\\zs\\S\\+')")
line 12:     silent! execute 'sunmap' map
line 13:     silent! execute 'sunmap <buffer>' map
line 14:   endfor
line 15: 
line 16:   " same behaviour of ultisnips
line 17:   snoremap <silent> <BS> <c-g>c
line 18:   snoremap <silent> <DEL> <c-g>c
line 19:   snoremap <silent> <c-h> <c-g>c
line 20:   snoremap <c-r> <c-g>"_c<c-r>
coc#snippet#_select_mappings returning #0

continuing in coc#snippet#enable

line 7:   let nextkey = get(g:, 'coc_snippet_next', '<C-j>')
line 8:   let prevkey = get(g:, 'coc_snippet_prev', '<C-k>')
line 9:   if maparg(nextkey, 'i') =~# 'snippet'
line 10:     let s:map_next = 0
line 11:   endif
line 12:   if maparg(prevkey, 'i') =~# 'snippet'
line 13:     let s:map_prev = 0
line 14:   endif
line 15:   if !empty(nextkey)
line 16:     if s:map_next
line 17:       execute 'inoremap <buffer><nowait><silent>'.nextkey." <C-R>=coc#snippet#jump(1, ".complete.")<cr>"
line 18:     endif
line 19:     execute 'snoremap <buffer><nowait><silent>'.nextkey." <Esc>:call coc#snippet#jump(1, ".complete.")<cr>"
line 19: snoremap <buffer><nowait><silent><tab> <Esc>:call coc#snippet#jump(1, 0)<cr>
line 20:   endif
line 21:   if !empty(prevkey)
line 22:     if s:map_prev
line 23:       execute 'inoremap <buffer><nowait><silent>'.prevkey." <C-R>=coc#snippet#jump(0, ".complete.")<cr>"
line 23: inoremap <buffer><nowait><silent><c-k> <C-R>=coc#snippet#jump(0, 0)<cr>
line 24:     endif
line 25:     execute 'snoremap <buffer><nowait><silent>'.prevkey." <Esc>:call coc#snippet#jump(0, ".complete.")<cr>"
line 25: snoremap <buffer><nowait><silent><c-k> <Esc>:call coc#snippet#jump(0, 0)<cr>
line 26:   endif
coc#snippet#enable returning #0

continuing in <SNR>13_request

calling coc#snippet#move({'character': 2, 'line': 4})

line 1:   let m = mode()
line 2:   if m == 's'
line 3:     call feedkeys("\<Esc>", 'in')
line 4:   endif
line 5:   let pos = coc#snippet#to_cursor(a:position)
calling coc#snippet#to_cursor({'character': 2, 'line': 4})
ben-wall commented 4 months ago

using :healthcheck I was able to find where I had a duplicate binding over<leader>a and remove it, and the issue resolved