Skip to content

Autocommands

github-actions[bot] edited this page Mar 28, 2024 · 90 revisions

core.autocommands

Handles the creation and management of Neovim's autocommands.

Overview

This internal module exposes functionality for subscribing to autocommands and performing actions based on those autocommands.

NOTE: This module will be soon deprecated, and it's favourable to use the vim.api* functions instead.

In your module.setup(), make sure to require core.autocommands (requires = { "core.autocommands" }) Afterwards in a function of your choice that gets called after core.autocommmands gets intialized (e.g. load()):

module.load = function()
    module.required["core.autocommands"].enable_autocommand("VimLeavePre") -- Substitute VimLeavePre for any valid neovim autocommand
end

Afterwards, be sure to subscribe to the event:

module.events.subscribed = {
    ["core.autocommands"] = {
        vimleavepre = true
    }
}

Upon receiving an event, it will come in this format:

{
    type = "core.autocommands.events.<name of autocommand, e.g. vimleavepre>",
    broadcast = true
}

Configuration

This module provides no configuration options!

Required By

Clone this wiki locally