File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 6
6
7
7
## Usage
8
8
9
- ### echo
9
+ ### echo / echoerr
10
10
11
11
Use ` echo() ` to show messages on the cmdline area. It is required while Vim
12
12
won't show messages reported from channel commands and it won't pause multi-line
@@ -18,10 +18,11 @@ properly show multi-line messages with `echomsg` from asynchronous context.
18
18
19
19
``` typescript
20
20
import { Denops } from " https://deno.land/x/denops_std/mod.ts" ;
21
- import { echo } from " https://deno.land/x/denops_std/helper/mod.ts" ;
21
+ import { echo , echoerr } from " https://deno.land/x/denops_std/helper/mod.ts" ;
22
22
23
23
export async function main(denops : Denops ): Promise <void > {
24
24
await echo (denops , " Hello\n World!" );
25
+ await echoerr (denops , " This is error message" );
25
26
}
26
27
```
27
28
Original file line number Diff line number Diff line change 1
1
import { deferred , Denops } from "../deps.ts" ;
2
2
import * as anonymous from "../anonymous/mod.ts" ;
3
+ import { batch } from "../batch/mod.ts" ;
3
4
import { load } from "./load.ts" ;
4
5
5
6
/**
@@ -23,6 +24,20 @@ export function echo(denops: Denops, message: string): Promise<void> {
23
24
}
24
25
}
25
26
27
+ /**
28
+ * Echo message as an error message.
29
+ *
30
+ * Note that this function just use ErrorMsg highlight and is not equivalent
31
+ * to `echoerr` command in Vim/Neovim.
32
+ */
33
+ export async function echoerr ( denops : Denops , message : string ) : Promise < void > {
34
+ await batch ( denops , async ( denops ) => {
35
+ await denops . cmd ( "echohl ErrorMsg" ) ;
36
+ await echo ( denops , message ) ;
37
+ await denops . cmd ( "echohl None" ) ;
38
+ } ) ;
39
+ }
40
+
26
41
async function echoVim ( denops : Denops , message : string ) : Promise < void > {
27
42
await load ( denops , new URL ( "./echo.vim" , import . meta. url ) ) ;
28
43
const waiter = deferred < void > ( ) ;
You can’t perform that action at this time.
0 commit comments