denops_std
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 { execute } 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);
// Use `call` to call Vim's function
const name = await fn.input(denops, "Your name: ");
// Use `eval` to evaluate Vim's expression
const progname = await vars.v.get(denops, "progname");
// Construct messages
const messages = [
`Hello ${where}`,
`Your name is ${name}`,
`This is ${progname}`,
];
// Use `cmd` to execute Vim's command
await denops.cmd(`redraw | echomsg message`, {
message: messages.join(". "),
});
},
};
// Use 'execute()' to execute multiline Vim script
await execute(
denops,
`
command! HelloWorld call denops#notify("${denops.name}", "say", ["World"])
command! HelloDenops call denops#notify("${denops.name}", "say", ["Denops"])
`,
);
}
See 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 |
function |
A module to provide functions of Vim and Neovim native functions |
helper |
A module to provide helper functions |
variable |
A module to provide helper accessor functions to variables |