Skip to content

Commit a1d5be8

Browse files
authored
Merge pull request #127 from vim-denops/fix-readme
🌿 Fix type checks on READMEs
2 parents f86e0e0 + 7570921 commit a1d5be8

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

denops_std/batch/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { Denops } from "https://deno.land/x/denops_std/mod.ts";
3232
import { batch } from "https://deno.land/x/denops_std/batch/mod.ts";
3333

3434
async function replace(denops: Denops, content: string): Promise<void> {
35-
await batch(denops, (denops) => {
35+
await batch(denops, async (denops) => {
3636
await denops.cmd("setlocal modifiable");
3737
await denops.cmd("setlocal foldmethod=manual");
3838
await denops.call("setline", 1, content.split(/\r?\n/));
@@ -78,7 +78,7 @@ import * as anonymous from "https://deno.land/x/denops_std/anonymous/mod.ts";
7878

7979
export async function main(denops: Denops): Promise<void> {
8080
await batch(denops, async (denops) => {
81-
const [id] = anonymous.add(denops, () => {
81+
const [id] = anonymous.add(denops, async () => {
8282
// This code is called outside of 'batch' block
8383
// thus the 'denops' instance works like a real one.
8484
// That's why you can write code like below
@@ -120,13 +120,14 @@ Note that `denops.call()` or `denops.eval()` always return falsy value in
120120

121121
```typescript
122122
import { Denops } from "https://deno.land/x/denops_std/mod.ts";
123-
import { batch } from "https://deno.land/x/denops_std/batch/mod.ts";
123+
import { gather } from "https://deno.land/x/denops_std/batch/mod.ts";
124124

125125
export async function main(denops: Denops): Promise<void> {
126126
const results = await gather(denops, async (denops) => {
127127
// !!! DON'T DO THIS !!!
128128
if (await denops.call("has", "nvim")) {
129-
await denops.call("api_info").version;
129+
// deno-lint-ignore no-explicit-any
130+
await (denops.call("api_info") as any).version;
130131
} else {
131132
await denops.eval("v:version");
132133
}

denops_std/function/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ in minimal supported Vim and Neovim versions.
1414
## Example
1515

1616
```typescript
17+
import { Denops } from "https://deno.land/x/denops_std/mod.ts";
1718
import * as fn from "https://deno.land/x/denops_std/function/mod.ts";
1819
import * as vimFn from "https://deno.land/x/denops_std/function/vim/mod.ts";
1920
import * as nvimFn from "https://deno.land/x/denops_std/function/nvim/mod.ts";
2021

21-
export async function main(denops) {
22+
export async function main(denops: Denops): Promise<void> {
2223
// fn holds functions exists in both Vim and Neovim
2324
console.log(fn.or(denops, 0, 1));
2425

denops_std/helper/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export async function main(denops: Denops): Promise<void> {
106106
cmdline: string,
107107
cursorpos: number,
108108
): Promise<string[]> => {
109-
return ["Hello", "World"];
109+
return Promise.resolve(["Hello", "World"]);
110110
},
111111
}),
112112
);
@@ -121,7 +121,7 @@ import { Denops } from "https://deno.land/x/denops_std/mod.ts";
121121
import { input } from "https://deno.land/x/denops_std/helper/mod.ts";
122122

123123
export async function main(denops: Denops): Promise<void> {
124-
denops.dispatch = {
124+
denops.dispatcher = {
125125
say: async () => {
126126
return await input(denops, {
127127
prompt: "> ",

denops_std/option/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,35 @@ minimal supported Vim and Neovim versions.
1414
## Example
1515

1616
```typescript
17+
import { Denops } from "https://deno.land/x/denops_std/mod.ts";
1718
import * as op from "https://deno.land/x/denops_std/option/mod.ts";
1819
import * as vimOp from "https://deno.land/x/denops_std/option/vim/mod.ts";
1920
import * as nvimOp from "https://deno.land/x/denops_std/option/nvim/mod.ts";
2021

21-
export async function main(denops) {
22+
export async function main(denops: Denops): Promise<void> {
2223
// Get value of the option.
2324
// `get` is available on any options
2425
// `getGlobal` is available on only global options
2526
// `getLocal` is available on only local options
26-
console.log(await op.filetype.get(denops));
27-
console.log(await op.filetype.getGlobal(denops));
28-
console.log(await op.filetype.getLocal(denops));
27+
console.log(await op.autoread.get(denops));
28+
console.log(await op.autoread.getGlobal(denops));
29+
console.log(await op.autoread.getLocal(denops));
2930

3031
// Set value of the option.
3132
// `set` is available on any options
3233
// `setGlobal` is available on only global options
3334
// `setLocal` is available on only local options
34-
await op.filetype.set(denops, "hello");
35-
await op.filetype.setGlobal(denops, "hello");
36-
await op.filetype.setLocal(denops, "hello");
35+
await op.autoread.set(denops, true);
36+
await op.autoread.setGlobal(denops, true);
37+
await op.autoread.setLocal(denops, true);
3738

3839
// Reset the option.
3940
// `reset` is available on any options
4041
// `resetGlobal` is available on only global options
4142
// `resetLocal` is available on only local options
42-
await op.filetype.reset(denops);
43-
await op.filetype.resetGlobal(denops);
44-
await op.filetype.resetLocal(denops);
43+
await op.autoread.reset(denops);
44+
await op.autoread.resetGlobal(denops);
45+
await op.autoread.resetLocal(denops);
4546

4647
// vimOp has options only exist in Vim
4748
console.log(await vimOp.compatible.get(denops));

denops_std/variable/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ export async function main(denops: Denops): Promise<void> {
164164
// Get option
165165
console.log(await options.get(denops, "filetype"));
166166
console.log(await localOptions.get(denops, "filetype"));
167-
console.log(await globalOption.get(denops, "filetype"));
167+
console.log(await globalOptions.get(denops, "filetype"));
168168

169169
// Reset option
170170
await options.remove(denops, "filetype");
171171
await localOptions.remove(denops, "filetype");
172-
await globalOption.remove(denops, "filetype");
172+
await globalOptions.remove(denops, "filetype");
173173
}
174174
```
175175

0 commit comments

Comments
 (0)