Skip to content

Commit ed2af1f

Browse files
authored
Merge pull request #70 from kuuote/fn-2021-08-12
👍Correct type of `mode()`
2 parents eca274c + 35f83fa commit ed2af1f

File tree

4 files changed

+69
-51
lines changed

4 files changed

+69
-51
lines changed

denops_std/function/_generated.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4470,57 +4470,6 @@ export function mkdir(denops: Denops, ...args: unknown[]): Promise<unknown> {
44704470
return denops.call("mkdir", ...args);
44714471
}
44724472

4473-
/**
4474-
* Return a string that indicates the current mode.
4475-
* If [expr] is supplied and it evaluates to a non-zero Number or
4476-
* a non-empty String (|non-zero-arg|), then the full mode is
4477-
* returned, otherwise only the first letter is returned.
4478-
* Also see |state()|.
4479-
* n Normal, Terminal-Normal
4480-
* no Operator-pending
4481-
* nov Operator-pending (forced characterwise |o_v|)
4482-
* noV Operator-pending (forced linewise |o_V|)
4483-
* noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|);
4484-
* CTRL-V is one character
4485-
* niI Normal using |i_CTRL-O| in |Insert-mode|
4486-
* niR Normal using |i_CTRL-O| in |Replace-mode|
4487-
* niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
4488-
* v Visual by character
4489-
* V Visual by line
4490-
* CTRL-V Visual blockwise
4491-
* s Select by character
4492-
* S Select by line
4493-
* CTRL-S Select blockwise
4494-
* i Insert
4495-
* ic Insert mode completion |compl-generic|
4496-
* ix Insert mode |i_CTRL-X| completion
4497-
* R Replace |R|
4498-
* Rc Replace mode completion |compl-generic|
4499-
* Rv Virtual Replace |gR|
4500-
* Rx Replace mode |i_CTRL-X| completion
4501-
* c Command-line editing
4502-
* cv Vim Ex mode |gQ|
4503-
* ce Normal Ex mode |Q|
4504-
* r Hit-enter prompt
4505-
* rm The -- more -- prompt
4506-
* r? A |:confirm| query of some sort
4507-
* ! Shell or external command is executing
4508-
* t Terminal-Job mode: keys go to the job
4509-
* This is useful in the 'statusline' option or when used
4510-
* with |remote_expr()| In most other places it always returns
4511-
* "c" or "n".
4512-
* Note that in the future more modes and more specific modes may
4513-
* be added. It's better not to compare the whole string but only
4514-
* the leading character(s).
4515-
* Also see |visualmode()|.
4516-
* Can also be used as a |method|:
4517-
* DoFull()->mode()
4518-
*/
4519-
export function mode(denops: Denops, expr?: unknown): Promise<unknown>;
4520-
export function mode(denops: Denops, ...args: unknown[]): Promise<unknown> {
4521-
return denops.call("mode", ...args);
4522-
}
4523-
45244473
/**
45254474
* Return the line number of the first line at or below {lnum}
45264475
* that is not blank. Example:

denops_std/function/_manual.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from "./buffer.ts";
22
export * from "./common.ts";
33
export * from "./cursor.ts";
44
export * from "./types.ts";
5+
export * from "./various.ts";

denops_std/function/various.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Denops } from "../deps.ts";
2+
3+
/**
4+
* Return a string that indicates the current mode.
5+
* If [expr] is supplied and it evaluates to a non-zero Number or
6+
* a non-empty String (|non-zero-arg|), then the full mode is
7+
* returned, otherwise only the first letter is returned.
8+
* Also see |state()|.
9+
* n Normal, Terminal-Normal
10+
* no Operator-pending
11+
* nov Operator-pending (forced characterwise |o_v|)
12+
* noV Operator-pending (forced linewise |o_V|)
13+
* noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|);
14+
* CTRL-V is one character
15+
* niI Normal using |i_CTRL-O| in |Insert-mode|
16+
* niR Normal using |i_CTRL-O| in |Replace-mode|
17+
* niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
18+
* v Visual by character
19+
* V Visual by line
20+
* CTRL-V Visual blockwise
21+
* s Select by character
22+
* S Select by line
23+
* CTRL-S Select blockwise
24+
* i Insert
25+
* ic Insert mode completion |compl-generic|
26+
* ix Insert mode |i_CTRL-X| completion
27+
* R Replace |R|
28+
* Rc Replace mode completion |compl-generic|
29+
* Rv Virtual Replace |gR|
30+
* Rx Replace mode |i_CTRL-X| completion
31+
* c Command-line editing
32+
* cv Vim Ex mode |gQ|
33+
* ce Normal Ex mode |Q|
34+
* r Hit-enter prompt
35+
* rm The -- more -- prompt
36+
* r? A |:confirm| query of some sort
37+
* ! Shell or external command is executing
38+
* t Terminal-Job mode: keys go to the job
39+
* This is useful in the 'statusline' option or when used
40+
* with |remote_expr()| In most other places it always returns
41+
* "c" or "n".
42+
* Note that in the future more modes and more specific modes may
43+
* be added. It's better not to compare the whole string but only
44+
* the leading character(s).
45+
* Also see |visualmode()|.
46+
* Can also be used as a |method|:
47+
* DoFull()->mode()
48+
*/
49+
export function mode(denops: Denops, expr?: number | string): Promise<string> {
50+
return denops.call("mode", expr) as Promise<string>;
51+
}

denops_std/function/various_test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { test } from "../deps_test.ts";
2+
import * as various from "./various.ts";
3+
import { assertEquals } from "../deps_test.ts";
4+
5+
test({
6+
mode: "all",
7+
name: "mode()",
8+
fn: async (denops) => {
9+
const shortMode = denops.meta.host === "vim" ? "c" : "n";
10+
const longMode = denops.meta.host === "vim" ? "ce" : "n";
11+
assertEquals(await various.mode(denops), shortMode);
12+
assertEquals(await various.mode(denops, 0), shortMode);
13+
assertEquals(await various.mode(denops, 1), longMode);
14+
assertEquals(await various.mode(denops, ""), shortMode);
15+
assertEquals(await various.mode(denops, "v"), longMode);
16+
},
17+
});

0 commit comments

Comments
 (0)