Simple Neovim Function
- Source the file using
%so
- Run the command
:lua Todo()
Trigger
vim.api.nvim_create_user_command("Todo", Todo, {})
- Source the file and run:Todo
vim.api.nvim_create_auto_command("CursorHold", { callback = Todo })
- Source the file and hold the cursor and it will call the functionvim.keymap.set("n", "<leader>u", Todo
- Source the file and pressspace + u
on keyboard to trigger the function.
Creating Plugin
- make an empty lua directory (
mkdir lua
) - Add a file with your plugin name (
touch lua/<plugin-name>.lua
) - while opening the neovim, set the runtimepath
nvim --cmd "set rtp+=.
- require the plugin name (
require('NeovimConf').todo()
) - Important Note
Module
nvim --cmd "set rtp+=.
require('NeovimConf').todo()
Important Note
require caches the result. So, if we change the contents, it does not get reflected. So, we need to write a small script using
nvim_create_user_command
as below
we can type the command :Test, so that we make the cached result nil
and require again.