import * as denopsStd from "https://deno.land/x/denops_std@v6.5.1/popup/mod.ts";
A module to provide compatibility layer for popup window in Vim and Neovim.
import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.1/mod.ts";
import * as buffer from "https://deno.land/x/denops_std@v6.5.1/buffer/mod.ts";
import * as fn from "https://deno.land/x/denops_std@v6.5.1/function/mod.ts";
import * as popup from "https://deno.land/x/denops_std@v6.5.1/popup/mod.ts";
export const main: Entrypoint = async (denops) => {
// Create a new buffer
const bufnr = await fn.bufadd(denops, "");
await fn.bufload(denops, bufnr);
// Write some text to the buffer
await buffer.replace(denops, bufnr, ["Hello, world!"]);
// Open a popup window showing the buffer
const popupWindow = await popup.open(denops, {
bufnr,
relative: "editor",
width: 20,
height: 20,
row: 1,
col: 1,
});
// Config a popup window
await popup.config(denops, popupWindow.winid, {
title: "Hello, world!",
});
// Wiat 3 seconds
await new Promise((resolve) => setTimeout(resolve, 3000));
// Close the popup window
await popupWindow.close();
}
Or with await using
statement:
import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.1/mod.ts";
import * as buffer from "https://deno.land/x/denops_std@v6.5.1/buffer/mod.ts";
import * as fn from "https://deno.land/x/denops_std@v6.5.1/function/mod.ts";
import * as popup from "https://deno.land/x/denops_std@v6.5.1/popup/mod.ts";
export const main: Entrypoint = async (denops) => {
// Create a new buffer
const bufnr = await fn.bufadd(denops, "");
await fn.bufload(denops, bufnr);
// Write some text to the buffer
await buffer.replace(denops, bufnr, ["Hello, world!"]);
// Open a popup window showing the buffer
await using popupWindow = await popup.open(denops, {
bufnr,
relative: "editor",
width: 20,
height: 20,
row: 1,
col: 1,
});
// Wiat 3 seconds
await new Promise((resolve) => setTimeout(resolve, 3000));
// The popup window is automatically closed, due to `await using` statement
}
Note that this module does NOT work with batch.collect()
.