- Follow idiomatic Lua and Neovim plugin conventions.
- Use
require("...")for imports. - Prefer local modules and functions.
- Use snake_case for variables and functions; PascalCase for modules.
- Use early returns for error handling; avoid exceptions.
- Add
---@paramand similar Lua annotations for types when helpful. - Keep functions small and descriptive.
- Use descriptive, lowercase file names (e.g.,
persist_colorscheme.lua).
Keymaps:
-
For keymap blocks with long lines, use
-- stylua: ignore start...-- stylua: ignore endcomments around them. This prevents line wrapping. -
Avoid inline functions that span more than one line.
-- avoid vim.keymap.set("n", "<leader>xx", function() x() y() end, { desc = "xxx" }) -- consider local function descriptive_name() x() y() end vim.keymap.set("n", "<leader>xx", descriptive_name, { desc = "xxx" })
Keymap descriptions:
- Always have a
descfor each keymap. - For keymaps that open a prompt, add ellipsis at the end. Eg,
LSP: rename symbol… - For plugin keybindings, ensure
descis prefixed by the plugin, "Flash: jump to" rather than "Jump to".
When working with mini.nvim, consult the website for documentation, not context7. See https://github.com/nvim-mini/mini.nvim/tree/main/readmes