garymjr / nvim-snippets

Snippet support using native neovim snippets
MIT License
215 stars 13 forks source link

Bug: some `friendly-snippets` don't load in their filetype and some load in the wrong filetype #24

Closed benelan closed 3 months ago

benelan commented 3 months ago

Bug

From the source code, it appears this plugin is determining which snippet files to load based on file/directory names. Unfortunately, this doesn't work for a lot of the friendly-snippets files. A few examples of snippets not loading for their filetype are:

Additionally, typescript, react, nextjs, etc. snippets are incorrectly loaded in javascript files, because they are all in snippets/javascript/*.json.

Potential solution

It would be nice if this plugin parsed the package.json data to determine which snippet files to load. If that's out of this plugin's scope, then special cases would be needed to support friendly-snippets like the readme mentions.

Partial workaround

Some of the filename/filetype mismatches can be (kind of) resolved with the extend_filetypes config option, for example:

extended_filetypes = {
  sh = { "shell" },
  dockerfile = { "docker" }, -- loads unrelated docker-compose snippets too
  yaml = { "docker" },       -- for docker-compose users
}

Unfortunately, I haven't found a way to prevent typescript, react, etc. snippets from appearing in javascript files or a way to get vue, angular, etc. snippets to load.

benelan commented 3 months ago

Woops, I just found #5 and it looks like parsing the package.json data is planned, awesome!

I'm closing this one as a duplicate.