LuaSnip: tabstops, choices and Lua transforms inside Neovim
Snippet Engine for Neovim written in Lua.
At a glance
- What is it?
- LuaSnip is a snippet engine written in Lua for Neovim 0.9 and newer, aimed at people who want jumpable tabstops, choices and conditional expansion instead of fixed pasted text. The gains come with a build step for jsregexp and a rule that anything beyond LSP-syntax has to be written in Lua.
- Who is it for?
- Adopt LuaSnip if your snippets need choices, conditional expansion, Lua transformations or backward jumps, and if you are willing to stay on one major line and compile jsregexp through your plugin manager, since that build step is what makes LSP-style transforms work at all. Skip it if your snippets are plain blocks of text, because the VS Code loader alone covers those and none of the machinery is earning its cost.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 180 days ago.
- What is it written in?
- Mainly Lua, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- L3MON4D3/LuaSnip4,434 ★ · +7
| Repository | 2026-09-23 | 2026-11-15 |
|---|---|---|
| L3MON4D3/LuaSnip | 4.4k | 4.4k |
7 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Jumping backwards is the part snippets usually get wrong
Expanding a snippet strands your fingers. The block appears, the cursor lands at the end of it, and getting back to the third placeholder means arrow keys or the mouse. LuaSnip is a snippet engine for Neovim written in Lua, and its centre of gravity is that return trip: jump(1) moves forward through tabstops, ls.jump(-1) moves back, and the usual pattern is one key that expands a snippet and then jumps once one is active. Snippet history lets you jump back into older snippets, not only the one on screen. The people this is for are Neovim users who type code and configuration constantly and who have outgrown pasting identical blocks. If your snippets are fixed text with no structure, most of this machinery is dead weight.
Lua nodes behind an LSP-style snippet syntax
Two layers sit under the surface. The outer one is LSP-style snippet syntax, the same grammar VS Code uses, which LuaSnip parses directly in Lua, from a VS Code package or from a SnipMate snippet collection. The inner one is a node tree built in Lua, and that is where the features the syntax cannot express live: text transformations written as Lua functions, conditional expansion, nested snippets defined from other snippets, choice nodes you can cycle, regex triggers, autotriggered snippets and postfix snippets. Two details matter for day to day use. First, filetype is resolved at the cursor with Treesitter rather than only from the buffer, so a snippet can be chosen by the construct under the caret. Second, completion sources plug in from outside: LSP snippets expand through nvim-compe or its successor nvim-cmp, and the latter needs cmp_luasnip.
make install_jsregexp decides whether transforms run
LuaSnip requires Neovim 0.9 or newer, and a snippet transformation written in the LSP style needs `jsregexp`, a C library compiled by the Makefile at the repository root. With lazy.nvim that compilation happens as a build step, so the library is in place once the plugin is installed:
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp"
}On Windows that build step needs a C compiler and `make`, and if the compiler is not `gcc`, `clang` or `zig` you must name it in the command as make install_jsregexp CC=your_compiler_program. On FreeBSD the Makefile does not match the BSD variant of make, so install the GNU variant with pkg install gmake first. The README marks the build step optional, but jsregexp is listed as a requirement for LSP-snippet transformations.
Where a VS Code snippet package stops
The most common first move is to reuse an existing snippet collection instead of writing your own. The from_vscode loader reads any directory laid out like a VS Code extension. It needs one detail that trips people up: a `package.json` file must sit in the snippet directory, which is why the format looks strange at first if you have never opened one. Once loaded, the VS Code route and the Lua route diverge. The VS Code route is a file format in LSP-style snippet syntax, whose transformations need jsregexp. The Lua route is a program: transformations run a Lua function over the captured text, conditions decide whether a branch expands, and a choice node holds alternatives you cycle with a key. If your snippets never transform anything, the file format is enough. The moment you want an optional argument that changes the rest of the snippet, you are writing Lua nodes, and the README's own drawback note says exactly that.
The 95% figure argues against the Lua-only drawback
The drawbacks section says that snippets using the full functionality "have to be defined in Lua", then immediately adds that 95% of snippets can be written in LSP-syntax. Those two sentences pull in opposite directions, and the number is the more useful one. It says the Lua requirement is a minority tax, not an entry fee: a large collection can be plain syntax and the few clever ones can be code. What the count leaves open is who measured it, and the README gives no sample or collection size behind the figure, so treat it as a claim about typical collections rather than a guarantee about yours.
jumping between choice nodes needs its own mapping
Getting a snippet to expand is half the work. Once a choice node is active, the cursor can sit on several possible expansions, and the mapping set has to cover four actions: expand, jump forward, jump backward and change the active choice. The Lua mapping block below does all four, with a guard so that changing a choice only fires when one is actually active. The choice mapping is the one newcomers leave out, and its absence is silent: the snippet expands, the choice is there, and Ctrl-E does nothing.
local ls = require("luasnip")
vim.keymap.set({"i"}, "<C-K>", function() ls.expand() end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-L>", function() ls.jump( 1) end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-J>", function() ls.jump(-1) end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-E>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end, {silent = true})Both insert and select mode get the same jump behaviour, which is why the jump and choice mappings cover two modes. Before this, load a snippet collection, and for VS Code style ones one line is enough:
require("luasnip.loaders.from_vscode").lazy_load()Semantic versioning with leeway on patches
LuaSnip uses Semantic Versioning, with the qualification that big patches might ship as a Minor version, so the middle number is not a reliable signal of how much changed. Every manager example therefore pins a wildcard tag such as `v2.*` rather than tracking master. The last push to the repository was on 2026-05-19.
Editorial conclusion
Adopt LuaSnip if your snippets need choices, conditional expansion, Lua transformations or backward jumps, and if you are willing to stay on one major line and compile jsregexp through your plugin manager, since that build step is what makes LSP-style transforms work at all. Skip it if your snippets are plain blocks of text, because the VS Code loader alone covers those and none of the machinery is earning its cost. Verify three things before committing: that the make install_jsregexp build step completes on your platform, that ls.jump(-1) behaves in insert and select mode as your keymaps expect, and that the choice mapping is present, because a snippet whose choice node you cannot cycle still expands and looks fine while it is broken.
Frequently asked questions
how to install luasnip
Install it with your plugin manager and add `make install_jsregexp` as the build step if you want LSP-style snippet transformations. Neovim 0.9 or newer is required.
how to use luasnip
Map a key to `ls.expand()` and to `ls.jump(-1)` for backward movement, then load snippets with a loader such as `require("luasnip.loaders.from_vscode").lazy_load()`. You can also pass your own paths to load a custom snippet directory, which must contain a `package.json` file.
what does luasnip do
It expands snippets in Neovim and lets you move between tabstops in either direction with jump, and cycle choices with change_choice. Beyond LSP-style syntax it adds Lua transformations, conditional expansion, nested snippets, choice nodes, regex triggers, autotriggered and postfix snippets, snippet history, and filetype resolution at the cursor using Treesitter.
luasnip vscode
LuaSnip parses VS Code style snippets through the from_vscode loader, so an existing VS Code snippet collection can be reused instead of rewriting snippets. Anything needing conditional expansion must be written in Lua, and LSP-style transformations need jsregexp.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/l3mon4d3-luasnip)Star history chart for your README
[](https://hysenlabs.com/projects/l3mon4d3-luasnip)Was this useful?