denops_std

Test deno doc Documentation deno land

Deno module for denops.vim. This module is assumed to be used in denops plugin and the code is assumed to be called in a worker thread for a plugin.

By using this module, developers can write Vim/Neovim denops plugins like:

import { Denops } from "https://deno.land/x/denops_std/mod.ts";
import * as fn from "https://deno.land/x/denops_std/function/mod.ts";
import * as vars from "https://deno.land/x/denops_std/variable/mod.ts";
import * as helper from "https://deno.land/x/denops_std/helper/mod.ts";

import { ensureString } from "https://deno.land/x/unknownutil/mod.ts";

export async function main(denops: Denops): Promise<void> {
  denops.dispatcher = {
    async say(where: unknown): Promise<void> {
      // Ensure that `where` is `string` here
      ensureString(where);
      const name = await fn.input(denops, "Your name: ");
      const progname = await vars.v.get(denops, "progname");
      const messages = [
        `Hello ${where}.`,
        `Your name is ${name}.`,
        `This is ${progname}.`,
      ];
      await helper.echo(denops, messages.join("\n"));
    },
  };

  await helper.execute(
    denops,
    `
    command! HelloWorld call denops#notify("${denops.name}", "say", ["World"])
    command! HelloDenops call denops#notify("${denops.name}", "say", ["Denops"])
    `,
  );
}

See Denops Documentation or denops-helloworld.vim for more details.

Index

Name Description
anonymous A module to provide anonymous function
autocmd A module to provide helper functions to manage autocmd
batch A module to provide wrapper functions of denops.batch()
function A module to provide functions of Vim and Neovim native functions
helper A module to provide helper functions
mapping A module to provide helper functions to manage mappings
variable A module to provide helper accessor functions to variables