Skip to content

Commit be946b4

Browse files
authored
Merge pull request #36 from vim-denops/structural-change
πŸ’ͺ Move codes into `denops_std` directory
2 parents 3a7d194 + ea69466 commit be946b4

File tree

28 files changed

+56
-1
lines changed

28 files changed

+56
-1
lines changed

β€ŽMakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test: FORCE ## Test
2727
@deno test --unstable -A
2828

2929
dlink: FORCE ## Update dlink
30-
@${TOOLS}/bin/dlink
30+
(cd denops_std; ${TOOLS}/bin/dlink)
3131
@make fmt
3232

3333
FORCE:

β€Ždenops_std/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# denops_std
2+
3+
[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/denops_std)
4+
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/denops_std/mod.ts)
5+
[![Test](https://github.com/vim-denops/deno-denops-std/actions/workflows/test.yml/badge.svg)](https://github.com/vim-denops/deno-denops-std/actions/workflows/test.yml)
6+
7+
[Deno][deno] module for [denops.vim][denops.vim]. This module is assumed to be
8+
used in denops plugin and the code is assumed to be called in a worker thread
9+
for a plugin.
10+
11+
By using this module, developers can write Vim/Neovim denops plugins like:
12+
13+
```typescript
14+
import { Denops } from "https://deno.land/x/denops_std/mod.ts";
15+
import { execute } from "https://deno.land/x/denops_std/helper/mod.ts";
16+
import { ensureString } from "https://deno.land/x/unknownutil/mod.ts";
17+
18+
export async function main(denops: Denops): Promise<void> {
19+
denops.dispatcher = {
20+
async say(where: unknown): Promise<void> {
21+
// Ensure that `where` is `string` here
22+
ensureString(where);
23+
// Use `call` to call Vim's function
24+
const name = await denops.call("input", "Your name: ");
25+
// Use `eval` to evaluate Vim's expression
26+
const progname = await denops.eval("v:progname");
27+
// Construct messages
28+
const messages = [
29+
`Hello ${where}`,
30+
`Your name is ${name}`,
31+
`This is ${progname}`,
32+
];
33+
// Use `cmd` to execute Vim's command
34+
await denops.cmd(`redraw | echomsg message`, {
35+
message: messages.join(". "),
36+
});
37+
},
38+
};
39+
40+
// Use 'execute()' to execute multiline Vim script
41+
await execute(
42+
denops,
43+
`
44+
command! HelloWorld call denops#notify("${denops.name}", "say", ["World"])
45+
command! HelloDenops call denops#notify("${denops.name}", "say", ["Denops"])
46+
`,
47+
);
48+
}
49+
```
50+
51+
See [denops-helloworld.vim](https://github.com/vim-denops/denops-helloworld.vim)
52+
for more details.
53+
54+
[deno]: https://deno.land/
55+
[denops.vim]: https://github.com/vim-denops/denops.vim
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)