Using ~/.config/nvim/after/plugin For Neovim Mod Files

I'm experimenting with putting lua scripts to modify Neovim in:


Any `.lua`` files in that directory get loaded as one of the last parts of pulling things into the runtime. So, pretty much everything else should be loaded.

My thinking is to make it easier to break out parts of my config into the individual files and to make it easier to add little scripts to mod behavior.

For example, putting this script in the directory configures Neovim to print "File saved!" every time a file is written

vim.api.nvim_create_autocmd("BufWritePost", {
  group = vim.api.nvim_create_augroup("EaxmpleFileSaveMessage", { clear = true }),
  callback = function()
    print("File saved!")

That's not particullarly useful, but it proves the point that autocmds can be setup from the directory.


So far. So good. I've created a half dozen files and everything is working as expected.


after-directory Neovim Documentation

The subsection of the `runtimepath`` docs that talks about how the `after`` directories get loaded. Scoll up a bit to get a better idea of the entire process