theniceboy / coc-flutter-tools

Rich Flutter development experience for (Neo)vim
64 stars 5 forks source link

Super confused about how to get the snippets to work! #5

Closed unknowledgeable closed 4 years ago

unknowledgeable commented 4 years ago

I've been reading around about how snippets work with nvim, CoC and CoC extensions and I'm more confused now than when I started! I saw the option flutter.provider.enableSnippet and thought that would be cool but I have no idea how to access them. I've never used snippets before so apologies if this is super basic!

I've had a read of "Using snippets" but that confused me even more!

From what I can tell:

#now this is where I get really confused

What do I need to install and configure to use the snippets from coc-flutter-tools? Do I need any at all? How do I use them?

What does this mean from your readme? Are those the only things the coc-flutter-tools snippets can do or is there more?

    import ''; => import '${1}';${0}
    someName(…) => someName(${1})${0}
    setState(() {}); => setState(() {\n\t${1}\n});${0}

Is it worth using these as well as honza/vim-snippets or would they conflict and cause trouble?

Sorry for all the questions! Many thanks!

theniceboy commented 4 years ago

Yeah lol

Snippets in vim is a hot boiling piece of m***g mess mixed with some pure junk. There are different snippet engines, different formats of snippets, different ways of writing snippets, different ways of triggering snippets, and also different snippet providers. Nowadays, vim users usually use their own custom snippets alongside with some community maintained snippets (like vim-snippets).

Here's my dart/flutter snippets. These snippets have nothing to do with coc-flutter or coc-flutter-tools. Those are just Ultisnips-format (or more precisely coc-snippets specified Ultisnips format) snippets that can be triggered by Ultisnips or coc-snippets. I used to use ultisnips but it slowed down my vim too much so I switched to coc-snippets. Ultisnips provided more advanced python snippet usages but coc-snippets is way faster.

The difference between coc-snippets and coc-ultisnips is that coc-ultisnips actually requires Ultisnips (the vim plugin) to be installed in the first place. coc-ultisnips only grabs results from ultisnips and fills up your autocompletion menu.

    import ''; => import '${1}';${0}
    someName(…) => someName(${1})${0}
    setState(() {}); => setState(() {\n\t${1}\n});${0}

These three snippets have nothing to do with a snippet engine like Ultisnips, snipmate or coc-snippets. These snippets can be triggered when you press enter (or whatever you've configured to be the coc.nvim autocompletion menu confirm key) on them when they appear in your autocompletion menu. These are provided by the author of coc-flutter and I actually never use them, because it's way faster to trigger my own snippets.

If you want to use snippets, I recommend you to use coc-snippets as your snippet engine, and install vim-snippets to get started with. You can look at my configuration as a reference. Then you can start writing some custom snippets to suit your needs.

unknowledgeable commented 4 years ago

That's great, thanks so much for the write-up, cleared a lot of the confusion for me!