Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Neovim plugin that provides snippets for the LuaSnip plugin.

NotificationsYou must be signed in to change notification settings

dozken/LuaSnip-snippets.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 

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

Installation

{"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",  }) })

Config

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

User snippets

You add your own snippets by putting a lua file underlua/snippets/my-snippet-file.lua in yourvimrc directory.

How to compose snippets

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(")"),                    }),    }    }

Feel free to submit a PR.

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.

TODO

titledescription
setupmove away from refering to how doom-nvim installs LuaSnip to a simple general installer instructions.
creditsduring the initial development I crawled github for various snippets. Authors need to be credited approtriately.
helpersAdd 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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua100.0%

[8]ページ先頭

©2009-2025 Movatter.jp