Course Lessons
All the Tools You Need
So we’re ready to get autocompletion and snippets in our Neovim config. but I gotta come clean here. This is a really complicated topic. in Neovim, there isn’t a set standard for snippets and completion, like how there is for LSP functionality. nor is there a simple plugin that makes thing easy to understand, like how null-ls wraps CLI tools in an LSP and makes things easy with builtin tooling. Autocompletion and snippets require a hodgepodge of plugins to get the functionality we need for our config. I’ll try to go over each plugin in more detail, but for now, let me just lay out the list of plugins we’re looking at for this functionality.
- nvim-cmp (https://github.com/hrsh7th/nvim-cmp): the completion engine for neovim. This is the plugin that will show the completion list as you type. But this is only for completions, it still requires third party plugins for “sources” — like snippets for example.
- luasnip (https://github.com/L3MON4D3/LuaSnip): luasnip is a snippet engine for neovim written in lua. We are going to use luasnip as both a SOURCE of snippets for nvim-cmp, AND as the snippet expansion tool for nvim-cmp. You’ll see in a sec how this works.
- cmp_luasnip (https://github.com/saadparwaiz1/cmp_luasnip): this is luasnips completion source for nvim_cmp. from my understanding (and I could be wrong here). this plugin is responsible for supplying nvim_cmp with a LIST of POSSIBLE snippets while you type. then luasnip will expand them.
- friendly-snippets (https://github.com/rafamadriz/friendly-snippets): a collection of vs-code like snippets that can be loaded by luasnip. essentially adding awesome vscode snippets to luasnip. We will demonstrate this later.
- and finally cmp-nvim-lsp (https://github.com/hrsh7th/cmp-nvim-lsp): a completion source for nvim_cmp that displays the built in LSP completions offered by whatever LSP is attached to the buffer. I believe this adds an additional layer to our lsp sources, giving them the ability to report completions to nvim_cmp.
In the next sections. we're going to break down how all of these plugins work together to create a great snippet/autocompletion experience in neovim
You've completed this lesson!
You completed this lesson less than a minute ago.