Skip to content
Nicholas O'Kelley edited this page Sep 30, 2023 · 16 revisions

Welcome to the friendly-snippets wiki!

Snippets collection for a set of different programming languages for faster development. This repository has been forked from a couple of VSCode Snippets extensions in addition to individual developers contributions.

Snippets list:

As the snippets get individual pages, we will update this list to redirect to them 😎

Markup Languages

Programming Languages

Frameworks

  • Django
  • Docker
  • Docker Compose
  • EJS
  • Flutter
  • Jekyll
  • Kubernetes
  • Rails
  • Svelte
  • Vue
Game Engines
  • Godot (gdscript)
  • Unreal Engine

Extending Snippets

Below is an example of extending snippets, in particular making JavaScript React available for JavaScript files:

Note: This example uses nvim-cmp with Luasnip

require("luasnip").filetype_extend("typescript", { "javascript" })

For more specific implementations, see your snippet engines documentation.

Extending via lazy.nvim

-- Snippet Courtesy of @Zeioth, 

{
  "L3MON4D3/LuaSnip",
  build = vim.fn.has "win32" ~= 0 and "make install_jsregexp" or nil,
  dependencies = {
    "rafamadriz/friendly-snippets",
    "benfowler/telescope-luasnip.nvim",
  },
  config = function(_, opts)
    if opts then require("luasnip").config.setup(opts) end
    vim.tbl_map(
      function(type) require("luasnip.loaders.from_" .. type).lazy_load() end,
      { "vscode", "snipmate", "lua" }
    )
    -- friendly-snippets - enable standardized comments snippets
    require("luasnip").filetype_extend("typescript", { "tsdoc" })
    require("luasnip").filetype_extend("javascript", { "jsdoc" })
    require("luasnip").filetype_extend("lua", { "luadoc" })
    require("luasnip").filetype_extend("python", { "pydoc" })
    require("luasnip").filetype_extend("rust", { "rustdoc" })
    require("luasnip").filetype_extend("cs", { "csharpdoc" })
    require("luasnip").filetype_extend("java", { "javadoc" })
    require("luasnip").filetype_extend("c", { "cdoc" })
    require("luasnip").filetype_extend("cpp", { "cppdoc" })
    require("luasnip").filetype_extend("php", { "phpdoc" })
    require("luasnip").filetype_extend("kotlin", { "kdoc" })
    require("luasnip").filetype_extend("ruby", { "rdoc" })
    require("luasnip").filetype_extend("sh", { "shelldoc" })
  end,
},