nvim-lua-guide icon indicating copy to clipboard operation
nvim-lua-guide copied to clipboard

WIP: autocommands

Open nanotee opened this issue 3 years ago • 3 comments

nanotee avatar Feb 04 '22 22:02 nanotee

Done now, and API bike-shedding is over as well. Here the documentation should be good, too, and require very little expanding on.

clason avatar Apr 17 '22 10:04 clason

But apparently there's some confusion about user autocommands -- people seem not to be aware that these are just standard autocommands with User as the event and Whatever as the pattern (instead often believe that User is some special keyword and Whatever is the event).

Maybe having such an autocommand as one of the examples would be helpful.

clason avatar Apr 21 '22 22:04 clason

Is this PR being worked on? If not I can share a PR with a way of creating Autocommands using the latest Neovim v0.7 API.

For a heads up, here's an example of what it could look like:

local augroup_name = vim.api.nvim_create_augroup(
    "AutogroupName", 
    { clear = true }
)

vim.api.nvim_create_autocommand(
    "BufWritePost",
    {
        command = echo "Recent changes saved!",
        group = augroup_name,
        pattern = "*"
    }
)

For more information on the Autocommand API, refer to :h api-autocmd

Jarmos-san avatar Jun 12 '22 13:06 Jarmos-san