Neovim for Beginners — Code Annotation and Documentation
From the previous articles, we have configured the snippet plugin and also learned how to write custom snippets using the Lua language. Another important aspect of better coding is code documentation, annotation, and comment.
In this article, we are going to configure plugins to help us document our code, and integrate them with the snippet and completion engines.
This article is part of the Neovim for Beginners series.
The Neovim configuration files can be found in this repository.
Getting Started
We will walk through the configuration of 2 plugins.
These plugins support the documentation standards for commonly used languages. For demonstration purposes, we are going to configure and test out Lua, Python, Javascript/TypeScript, and Rust.
Neogen
Installation
In the lua/plugins.lua
file, add the lines to install the plugin.
use {
"danymat/neogen",
config = function()
require("config.neogen").setup()
end,
cmd = { "Neogen" },
module = "neogen",
disable = false,
}
We lazy load the plugin either when the Neogen
command is called or the module is required
Configuration
Create the lua/config/neogen.lua
file.
- We use
Luasnip
as the snippet engine, and configure it to integrate withNeogen
(line 5). - For each language, we specifically configure the documentation standard. For a list of supported languages, check out the documentation.
In the lua/config/whichkey.lua
file, we define the key mappings (<Leader> cg
and <Leader>cG
) to run the Neogen
command.