saadparwaiz1 / cmp_luasnip

luasnip completion source for nvim-cmp
Apache License 2.0
687 stars 32 forks source link

JSON snippets with autotrigger not in cmp menu #25

Closed lambtho12 closed 1 year ago

lambtho12 commented 2 years ago

Luasnip's commit @737a2e7 introduced the possibility to specify a "luasnip" field in a snippet JSON file so the snippets can autotrigger.

If that field is set and autotrigger is true, the snippet will not be listed in the nvim-cmp menu. I believe it should show up in the cmp menu, no matter the autotrigger behavior.

Example snippet config

  "uuid": {
    "prefix": "UUID",
    "body": [
      "${CURRENT_YEAR}${CURRENT_MONTH}${CURRENT_DATE}${CURRENT_HOUR}${CURRENT_MINUTE}"
    ],
    "description": "UUID",
    "luasnip": {
      "autotrigger": true
    }
  },
saadparwaiz1 commented 2 years ago

We don't do any filtering by autotrigger here. Unless autotrigger implies hidden?

Edit:

Never mind just saw that auto triggered snippets are stored in a different table. @L3MON4D3 do you want the auto trigger snippet table to show up in the completion menu or is it hidden by design. I can update the plugin once you give the go ahead :)

L3MON4D3 commented 2 years ago

I think they were hidden by design (and comfort, one less table to scan ;) ), I figured that autosnippets wouldn't be triggered via the completion-menu but, you know, automatically :D If there's demand for adding them, that shouldn't be a problem (autosnippets require a CharInsertPre to be expanded, but that isn't triggered while scrolling through the completion options)

lambtho12 commented 2 years ago

I personally have a large amount of snippets. It is not always easy to remember all of them and this is why I like to have visual clues when I start typing one.

If it does not impact performance and it does not autotrigger when scrolling over, I do not see any real reason to not list them as well.

saadparwaiz1 commented 2 years ago

Bit hesitant about implementing this just because I think competition menu should only show snippets that have to be triggered manually but I'll create a pull request for this and we can discuss more :)

saadparwaiz1 commented 2 years ago

you can try out #27 to see if this fixes it for you