Skip to main content
Module

x/denops_std/batch/mod.ts

📚 Standard module for denops.vim
Go to Latest
import * as denopsStd from "https://deno.land/x/denops_std@v6.4.0/batch/mod.ts";

A module to provide denops.batch() helper functions

import type { Denops } from "https://deno.land/x/denops_std@v6.4.0/mod.ts";
import { batch, collect } from "https://deno.land/x/denops_std@v6.4.0/batch/mod.ts";

export async function main(denops: Denops): Promise<void> {
  // Call multiple denops functions sequentially in a signle RPC call
  await batch(denops, async (denops) => {
    await denops.cmd("setlocal modifiable");
    await denops.cmd("setlocal noswap");
    await denops.cmd("setlocal nobackup");
  });

  // Call multiple denops functions sequentially and get the return values in a single RPC call
  const results = await collect(denops, (denops) => [
    denops.eval("&modifiable"),
    denops.eval("&modified"),
    denops.eval("&filetype"),
  ]);
  // results contains the value of modifiable, modified, and filetype
}

Functions

Call multiple denops functions sequentially without RPC overhead

Call multiple denops functions sequentially without RPC overhead and return values