If you need this section written in Japanese, read article written by @lambdalisue
You need to install these softwares on your machine to run denops plugins.
- Deno (latest stable version is recommended.)
- Vim/Neovim
TODO: check minimum/maximum versions of each deps.
We need to install both denops itself and plugins you'd like to use.
TODO: write how to install with each plugin managers like vim-plug
, dein.vim
or etc.
Denops plugins must be in the runtimepath of Vim/neovim since they're also Vim plugin.
set runtimepath^=~/your-plugin-root
And set option in your vimrc in order to change arguments of deno called by denops, which enables deno runtime type checker.
let g:denops#server#service#deno_args = [
\ '-q',
\ '--unstable',
\ '-A',
\]
Denops checks if denops/*/app.ts
exists in runtimepath of vim recursively, hence denops plugin usually looks like this:
`dps-helloworld` (project root)
|- `denops` (folder)
|- `helloworld` (folder, we reccomend to name same as your plugin.) - [^1]
|- `app.ts` (main file of this plugin. must include entrypoint of denops.)
|- `deps.ts`
|- `xxx.ts`
|- ...
import { main } from "https://deno.land/x/denops_std/mod.ts";
// main entrypoint.
// Call 'main' with async callback. The callback get `RunnerContext`.
main(async ({ vim }) => {
// Register RPC functions with 'vim.register' like:
vim.register({
async draw(text: unknown): Promise<void> {
// Ensure that `prefix` is 'string' here
// https://doc.deno.land/https/deno.land/x/denops_core/mod.ts#ensureString
ensureString(text, "text");
// Use `cmd` to execute Vim's command
await vim.cmd(`redraw | echomsg message`, {
message: text,
});
},
});
// Use 'vim.execute()' to execute Vim script
await vim.execute(`
command! HelloWorld call denops#notify("${vim.name}", "drow", ["Hello World"])
`);
});
If you need detail of each functions, see deno docs below.