Home

Awesome

<div align="center">

snippet-converter.nvim

Parse, transform and convert snippets. Supports a variety of formats and snippet engines.

Neovim Lua

<video src="https://user-images.githubusercontent.com/40792180/166674215-61bd1e8c-c307-4db9-bca1-a71f873e00ff.mp4" width="85%"> </div>

Primary objectives

Use cases

There are several cases where this plugin comes in handy:

Other reasons may include:

Supported snippet engines

SnippetConverter can convert snippets between the following formats:

Is there any other snippet engine or custom format that you think should be supported? Let me know by creating an issue!

Requirements

Getting started

To get started, pass a Lua table with a list of templates to the setup function. A template must contain sources (the formats and paths of your input snippets) and output tables (the target formats and paths).

Here's an example to convert a set of UltiSnips and SnipMate snippets to the VSCode snippets format (using packer.nvim):

use {
  "smjonas/snippet-converter.nvim",
  -- SnippetConverter uses semantic versioning. Example: use version = "1.*" to avoid breaking changes on version 1.
  -- Uncomment the next line to follow stable releases only.
  -- tag = "*",
  config = function()
    local template = {
      -- name = "t1", (optionally give your template a name to refer to it in the `ConvertSnippets` command)
      sources = {
        ultisnips = {
          -- Add snippets from (plugin) folders or individual files on your runtimepath...
          "./vim-snippets/UltiSnips",
          "./latex-snippets/tex.snippets",
          -- ...or use absolute paths on your system.
          vim.fn.stdpath("config") .. "/UltiSnips",
        },
        snipmate = {
          "vim-snippets/snippets",
        },
      },
      output = {
        -- Specify the output formats and paths
        vscode_luasnip = {
          vim.fn.stdpath("config") .. "/luasnip_snippets",
        },
      },
    }

    require("snippet_converter").setup {
      templates = { template },
      -- To change the default settings (see configuration section in the documentation)
      -- settings = {},
    }
  end
}

Then simply run the command :ConvertSnippets to convert all snippets to your specified output locations and formats. To see which output folders you should choose depending on your snippet engine, have a look at the section Recommended output paths in the docs.

Documentation

For more detailed instructions, info about customization and examples check out the documentation or help file with :h snippet-converter.

Credits

I want to thank