lua/magictt/plugins/ directory.
Plugin Structure
All plugins are stored inlua/magictt/plugins/. Each plugin file should return a table containing one or more plugin specifications.
Basic Plugin Structure
Plugin with Configuration
Adding a New Plugin
Add the plugin specification
Open the file and add your plugin configuration. Here’s an example based on the Comment.nvim plugin:
Restart Neovim
Lazy.nvim will automatically detect and load the new plugin file when you restart Neovim.You can also use
:Lazy sync to install the plugin without restarting.Real Examples from Magictt
Simple Plugin (init.lua:1-4)
Plugin with Dependencies (telescope.lua:1-9)
Plugin with Keymaps (telescope.lua:29-36)
Many plugins define their keymaps within the config function:Plugin Specification Options
Common Options
dependencies- Other plugins this plugin depends onevent- Lazy load on specific events (e.g.,"BufReadPre","BufNewFile")cmd- Lazy load on specific commandsft- Lazy load on specific filetypeskeys- Lazy load on specific keymapsconfig- Function to run after plugin is loadedopts- Table passed torequire("plugin").setup(opts)build- Command to run after install/updatebranch- Git branch to use
Lazy Loading
Lazy loading improves startup time by only loading plugins when needed:Multiple Plugins per File
You can define multiple plugins in a single file by returning a table of tables:Auto-loading
Lazy.nvim automatically discovers and loads all.lua files in:
lua/magictt/plugins/lua/magictt/plugins/lsp/(subdirectories are also supported)
Managing Plugins
Lazy Commands
:Lazyor<leader>ln- Open Lazy panel:Lazy sync- Install missing plugins and update:Lazy clean- Remove unused plugins:Lazy update- Update plugins:Lazy profile- Profile plugin load times
Best Practices
- One plugin per file - Easier to manage and understand
- Use descriptive filenames - Match the plugin name (e.g.,
telescope.lua,nvim-tree.lua) - Lazy load when possible - Use
event,cmd, orftto improve startup time - Add comments - Explain what the plugin does
- Group related plugins - Use subdirectories for related plugins (e.g.,
lsp/)