A very simple Neovim plugin to help keep your configurations clean by creating autocmds for files in folders specified from your plugin configuration.
- Creates autocmds from plugin configuration
- Autocmds are trigged for all files/subfolders within given directory
- Can specify lua function or vim command to be trigged
- Enable/Disable autocmds during runtime
- Command to temporarily run a command without generated autocmds
Lazy:
{
"smtucker/autodircmds"
opts = {
dirs = {
["~/notes"] = {
["BufReadPre"] = "!sync-notes down %", -- external shell script
["BufWritePost"] = function(event)
-- Your code here
end,
},
},
},
lazy = false,
},
All autocmds are created in a augroup so the plugin can toggle them on and off.
To disable the autocmds generated by the plugin you can use the ADCDisable
,
and then you can re-enable them with ADCEnable
.
The plugin also supplies a ADCRunWithout
vim command that allows you to pass a
command to be run with the autocmds temporarily disabled.
All of the above have corresponding Lua functions you can call from your code as well.
For example:
local ADC = require("autodircmds")
ADC.disable()
ADC.enable()
ADC.run_without(lua_func, args)