smjonas / snippet-converter.nvim

Bundle snippets from multiple sources and convert them to your format of choice.
Mozilla Public License 2.0
174 stars 4 forks source link

Snippets from unrelated filetypes get merged (SnipMate) #4

Closed dcampos closed 2 years ago

dcampos commented 2 years ago

It looks like snippet-converter doesn't separate snippets from different filetypes correctly when outputting to SnipMate format from Json. Below is a minimal example I've put together.

Configuration:

local template = {
    sources = {
        vscode = {
            '~/tmp/jsonsnips/'
        }
    },
    output = {
        snipmate = {
            '/tmp/snippets',
        }
    }
}
require('snippet_converter').setup({
    templates = { template, }
})

I have two snippet files, java.json and lua.json, each containing a single snippet. When I run :ConvertSnippets, I get the following lua.snippets file, containing both snippets:

# Generated by snippet-converter.nvim (https://github.com/smjonas/snippet-converter.nvim)

snippet foreach Enhanced for loop This is a new line And another one
    for (${1:type} ${2:var} : ${3:iterable}) {
        $0
    }
snippet req Require module
    require("${1:module}")

Sometimes it's the corresponding java.snippets that gets the merged snippets and lua.snippets is correct. At other times, both will get both snippets. It seems random.

When there are multiple filetypes, things get worse.

smjonas commented 2 years ago

Thank you, it should be working as expected now. If not, feel free to reopen!

dcampos commented 2 years ago

Thanks!