@@ -68,7 +68,7 @@ import { open, reload } from "../buffer/mod.ts";
6868
6969export async function main(denops : Denops ): Promise <void > {
7070 await open (denops , " README.md" );
71- const bufnr = await fn .bufnr (denops ) as number ;
71+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
7272 // ...
7373 // Reload the content of the `bufnr` buffer.
7474 await reload (denops , bufnr );
@@ -90,7 +90,7 @@ import { decode, open, replace } from "../buffer/mod.ts";
9090
9191export async function main(denops : Denops ): Promise <void > {
9292 await open (denops , " README.md" );
93- const bufnr = await fn .bufnr (denops ) as number ;
93+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
9494 const data = await Deno .readFile (" README.md" );
9595 const { content } = await decode (denops , bufnr , data );
9696 await replace (denops , bufnr , content );
@@ -111,7 +111,7 @@ import { append, open } from "../buffer/mod.ts";
111111
112112export async function main(denops : Denops ): Promise <void > {
113113 await open (denops , " README.md" );
114- const bufnr = await fn .bufnr (denops ) as number ;
114+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
115115 // Append the content under the cursor position of the `bufnr` buffer
116116 await append (denops , bufnr , [" Hello" , " World" ]);
117117}
@@ -131,7 +131,7 @@ import { open, replace } from "../buffer/mod.ts";
131131
132132export async function main(denops : Denops ): Promise <void > {
133133 await open (denops , " README.md" );
134- const bufnr = await fn .bufnr (denops ) as number ;
134+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
135135 // Set the content of the `bufnr` buffer
136136 await replace (denops , bufnr , [" Hello" , " World" ]);
137137}
@@ -153,7 +153,7 @@ import { assign, open } from "../buffer/mod.ts";
153153
154154export async function main(denops : Denops ): Promise <void > {
155155 await open (denops , " README.md" );
156- const bufnr = await fn .bufnr (denops ) as number ;
156+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
157157 const content = await Deno .readFile (" README.md" );
158158 await assign (denops , bufnr , content );
159159}
@@ -171,7 +171,7 @@ import { assign, open } from "../buffer/mod.ts";
171171
172172export async function main(denops : Denops ): Promise <void > {
173173 await open (denops , " README.md" );
174- const bufnr = await fn .bufnr (denops ) as number ;
174+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
175175 const content = await Deno .readFile (" README.md" );
176176 // A preprocessor that replace all non words to "-"
177177 const preprocessor = (repl : string []): string [] => {
@@ -194,7 +194,7 @@ import { concrete, open, replace } from "../buffer/mod.ts";
194194
195195export async function main(denops : Denops ): Promise <void > {
196196 await open (denops , " README.md" );
197- const bufnr = await fn .bufnr (denops ) as number ;
197+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
198198 await fn .setbufvar (denops , bufnr , " &buftype" , " nofile" );
199199 await replace (denops , bufnr , [" Hello" , " World" ]);
200200 await concrete (denops , bufnr );
@@ -215,7 +215,7 @@ import { ensure, open } from "../buffer/mod.ts";
215215
216216export async function main(denops : Denops ): Promise <void > {
217217 await open (denops , " README.md" );
218- const bufnr = await fn .bufnr (denops ) as number ;
218+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
219219 // ...
220220 await ensure (denops , bufnr , async () => {
221221 await option .buftype .set (denops , " nofile" );
@@ -239,7 +239,7 @@ import { modifiable, open } from "../buffer/mod.ts";
239239
240240export async function main(denops : Denops ): Promise <void > {
241241 await open (denops , " README.md" );
242- const bufnr = await fn .bufnr (denops ) as number ;
242+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
243243 // ...
244244 await modifiable (denops , bufnr , async () => {
245245 await fn .setline (denops , 1 , [" Hello" , " World" ]);
@@ -258,7 +258,7 @@ import { decorate, open } from "../buffer/mod.ts";
258258
259259export async function main(denops : Denops ): Promise <void > {
260260 await open (denops , " README.md" );
261- const bufnr = await fn .bufnr (denops ) as number ;
261+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
262262 // ...
263263 await decorate (denops , bufnr , [
264264 {
@@ -277,5 +277,43 @@ export async function main(denops: Denops): Promise<void> {
277277}
278278```
279279
280+ It uses ` prop_add_list ` in Vim and ` nvim_buf_add_highlight ` in Neovim to
281+ decorate the buffer.
282+
283+ ### undecorate
284+
285+ Use ` undecorate() ` to undecorate the ` bufnr ` buffer decorated with ` decorate `
286+ like:
287+
288+ ``` typescript
289+ import { Denops } from " ../mod.ts" ;
290+ import * as fn from " ../function/mod.ts" ;
291+ import { decorate , open , undecorate } from " ../buffer/mod.ts" ;
292+
293+ export async function main(denops : Denops ): Promise <void > {
294+ await open (denops , " README.md" );
295+ const bufnr = (await fn .bufnr (denops )) as number ;
296+ // ...
297+ await decorate (denops , bufnr , [
298+ {
299+ line: 1 ,
300+ column: 1 ,
301+ length: 10 ,
302+ highlight: " Special" ,
303+ },
304+ {
305+ line: 2 ,
306+ column: 2 ,
307+ length: 3 ,
308+ highlight: " Comment" ,
309+ },
310+ ]);
311+
312+ // Do something
313+
314+ await undecorate (denops , bufnr );
315+ }
316+ ```
317+
280318It uses ` prop_add ` in Vim and ` nvim_buf_add_highlight ` in Neovim to decorate the
281319buffer.
0 commit comments