Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/denops_std/function/nvim/mod.ts>nvim_get_autocmds

📚 Standard module for denops.vim
Go to Latest
function nvim_get_autocmds
import { nvim_get_autocmds } from "https://deno.land/x/denops_std@v5.1.0/function/nvim/mod.ts";

Get all autocommands that match the corresponding {opts}.

These examples will get autocommands matching ALL the given criteria:

-- Matches all criteria
autocommands = vim.api.nvim_get_autocmds({
  group = "MyGroup",
  event = {"BufEnter", "BufWinEnter"},
  pattern = {"*.c", "*.h"}
})

-- All commands from one group
autocommands = vim.api.nvim_get_autocmds({
  group = "MyGroup",
})

NOTE: When multiple patterns or events are provided, it will find all the autocommands that match any combination of them.

Parameters: {opts} Dictionary with at least one of the following: - group (string|integer): the autocommand group name or id to match against. - event (string|array): event or events to match against autocmd-events. - pattern (string|array): pattern or patterns to match against autocmd-pattern. Cannot be used with {buffer} - buffer: Buffer number or list of buffer numbers for buffer local autocommands autocmd-buflocal. Cannot be used with {pattern}

Return: Array of autocommands matching the criteria, with each item containing the following fields: - id (number): the autocommand id (only when defined with the API). - group (integer): the autocommand group id. - group_name (string): the autocommand group name. - desc (string): the autocommand description. - event (string): the autocommand event. - command (string): the autocommand command. Note: this will be empty if a callback is set. - callback (function|string|nil): Lua function or name of a Vim script function which is executed when this autocommand is triggered. - once (boolean): whether the autocommand is only run once. - pattern (string): the autocommand pattern. If the autocommand is buffer local autocmd-buffer-local: - buflocal (boolean): true if the autocommand is buffer local. - buffer (number): the buffer number.

Parameters

denops: Denops
opts: unknown

Returns

Promise<unknown>