Neovim for Beginners — Snippets using Lua

Better coding experience using snippets.

alpha2phi
6 min readApr 18, 2022
Neovim for Beginners — Snippets using Lua

In the previous article, we configured snippets plugins and wrote our snippets using Lua. We will build on the existing setup and improve the configuration to help us code more efficiently. We are going to

  • Refactor existing configuration to use Lua snippets loader.
  • Go through Luasnip basics.
  • Develop code snippets to help us code more efficiently.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

Lua Snippets Loader

In the previous article, we separated our snippets by the languages under the lua/config/snip/snippets folder, and use an autocmd to load the snippet files. For Luasnip, there is a better way to do this now. We are going to refactor our configuration to use the Lua snippets loader.

Lua Snippets

We already used the VSCode snippets loader and Snipmate snippets loader in the lua/config/snip/init.lua file. To load the Lua snippets, add the following lines of…

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.