
Basic Neovim Plugin Development Tutorial
Basic Plugin File
Just take my ColorfulDiff.nvim as an example.
1 | tree ColorfulDiff.nvim |
The lua scripts in plugin/ will be executed automatically and the scripts in lua/ will be called when required
To let nvim load the plugin, use lazy.nvim.
Add this line in your lazy.nvim configuration:
1 | { dir = "/home/cyl/nvim_plugins/ColorfulDiff.nvim/" }, |
Then this plugin will be loaded on start.
How To Use API
Use :Telescope help_tags or short hand <Ctrl-h> to open the help search panel.
If I want to know the API regarding the highlight:
1 | *nvim_buf_add_highlight()* |
To use this api:
1 | vim.api.nvim_buf_add_highlight(...) |
Test
Create a new folder called test
And create the test lua file
1 | describe("colorfulDiff", function() |
然后在该文件中按<leader>pt运行测试
1 | :h lua-plugin |
Basic Neovim Plugin Development Tutorial

