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 = ['[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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.