- Notifications
You must be signed in to change notification settings - Fork0
dozken/LuaSnip-snippets.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a plugin that aims to provide a community driven library ofLuaSnip snipets and also make it easy to add LuaSnip snippets to neovim
{"dozken/LuaSnip-snippets.nvim",dependencies= {"L3MON4D3/LuaSnip" },config=function()localluasnip=require"luasnip"luasnip.snippets=require("luasnip_snippets").load_snippets()end}The following is anexample of how LuaSnip is installed indoom-nvim with thepacker package manager.
use({"hrsh7th/nvim-cmp",commit=pin_commit("2e4270d02843d15510b3549354e238788ca07ca5"),wants= {"LuaSnip"},requires= { {"L3MON4D3/LuaSnip",commit=pin_commit("a54b21aee0423dbdce121c858ad6a88a58ef6e0f"),event="BufReadPre",wants="friendly-snippets",config=require("doom.modules.config.doom-luasnip"),disable=disabled_snippets,requires= {"rafamadriz/friendly-snippets","luasnip_snippets.nvim", }, }, {"windwp/nvim-autopairs",commit=pin_commit("e6b1870cd2e319f467f99188f99b1c3efc5824d2"),config=require("doom.modules.config.doom-autopairs"),disable=disabled_autopairs,event="BufReadPre", }, },config=require("doom.modules.config.doom-cmp"),disable=disabled_lsp,event="InsertEnter", }) })
This snippet solely aims to show how you hookLuaSnip into your config. Be sure to check outLuaSnip repo for further configurations.
returnfunction()localluasnip=require("luasnip")-- be sure to load this first since it overwrites the snippets table.luasnip.snippets=require("luasnip_snippets").load_snippets()......end
You add your own snippets by putting a lua file underlua/snippets/my-snippet-file.lua in yourvimrc directory.
Here follows an example of a snippet file that you can put inside yourlua/snippets directory. As you can see below the snippets are assigned to their respective language key, and hence if you like you can either put all your snippets into their own file or you can put all of your snippets in a single file - just be sure to assign them to the correct language key.
localls=require("luasnip")locals=ls.snippetlocalt=ls.text_nodelocali=ls.insert_nodelocalr=require("luasnip.extras").repreturn {lua= {s("print_str", {t("print(\""),i(1,"desrc"),t("\")"), }),s("print_var1", {t("print(\""),i(1,"desrc"),t(":\" .."),i(2,"the_variable"),t(")"), }),s("print_var2", {t("print(\""),i(1,"the_variable"),t(":\" .."),r(1),t(")"), }),s("print_var3", {t("print(\""),i(1,"desrc"),t(" |"),i(2,"the_variable"),t(" :\" .."),r(2),t(")"), }), } }
I encourage anyone who wants to submit their own snippets. At the moment this plugin is quite small but it has some handy snippets already. If you decide to submit snippets please add them to their appropriate language file if it exists or create a new one if necessary. Otherwise please provide a good explanation for why you have grouped multiple language snippets into one file.
| title | description |
|---|---|
| setup | move away from refering to how doom-nvim installs LuaSnip to a simple general installer instructions. |
| credits | during the initial development I crawled github for various snippets. Authors need to be credited approtriately. |
| helpers | Add more helper snippets for making it easy to create luasnippets which can seem rather daunting at first. |
About
Neovim plugin that provides snippets for the LuaSnip plugin.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Lua100.0%