2

By following this guide, I could get a simple snippet working.

" vim source for emails
function! coc#source#email#init() abort
  return {
        \ 'priority': 9,
        \ 'shortcut': 'Email',
        \ 'triggerCharacters': ['@']
        \}
endfunction

function! coc#source#email#complete(opt, cb) abort
  let items = ['foo@gmail.com', 'bar@yahoo.com']
  call a:cb(items)
endfunction

But I want when user types something like afc and hit enter in the correct item in the menu. What coc.nvim should enter to the buffer is following. .

() => {

}

I don't know what this triggerCharacters option is but it certainly not the characters I should enter in the buffer to get the auto completion menu open because it's not showing up in the menu.

How can I do this?

s1n7ax
  • 2,750
  • 6
  • 24
  • 53

1 Answers1

4

The guide you linked is not for snippets, but custom source.

Install coc-snippets like: :CocInstall coc-snippets

Then :CocCommand snippets.editSnippets to create a snippet(for filetype open), for example:

snippet afc "Description"
    () => {
        ${0:${VISUAL}}
    }
endsnippet

then you can trigger it by afc.

TUSqasi
  • 750
  • 6
  • 13
fannheyward
  • 18,599
  • 12
  • 71
  • 109