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 = ['[email protected]', '[email protected]']
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?
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
.