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.
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…