@@ -68,7 +68,7 @@ import { open, reload } from "../buffer/mod.ts";
68
68
69
69
export async function main(denops : Denops ): Promise <void > {
70
70
await open (denops , " README.md" );
71
- const bufnr = await fn .bufnr (denops ) as number ;
71
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
72
72
// ...
73
73
// Reload the content of the `bufnr` buffer.
74
74
await reload (denops , bufnr );
@@ -90,7 +90,7 @@ import { decode, open, replace } from "../buffer/mod.ts";
90
90
91
91
export async function main(denops : Denops ): Promise <void > {
92
92
await open (denops , " README.md" );
93
- const bufnr = await fn .bufnr (denops ) as number ;
93
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
94
94
const data = await Deno .readFile (" README.md" );
95
95
const { content } = await decode (denops , bufnr , data );
96
96
await replace (denops , bufnr , content );
@@ -111,7 +111,7 @@ import { append, open } from "../buffer/mod.ts";
111
111
112
112
export async function main(denops : Denops ): Promise <void > {
113
113
await open (denops , " README.md" );
114
- const bufnr = await fn .bufnr (denops ) as number ;
114
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
115
115
// Append the content under the cursor position of the `bufnr` buffer
116
116
await append (denops , bufnr , [" Hello" , " World" ]);
117
117
}
@@ -131,7 +131,7 @@ import { open, replace } from "../buffer/mod.ts";
131
131
132
132
export async function main(denops : Denops ): Promise <void > {
133
133
await open (denops , " README.md" );
134
- const bufnr = await fn .bufnr (denops ) as number ;
134
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
135
135
// Set the content of the `bufnr` buffer
136
136
await replace (denops , bufnr , [" Hello" , " World" ]);
137
137
}
@@ -153,7 +153,7 @@ import { assign, open } from "../buffer/mod.ts";
153
153
154
154
export async function main(denops : Denops ): Promise <void > {
155
155
await open (denops , " README.md" );
156
- const bufnr = await fn .bufnr (denops ) as number ;
156
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
157
157
const content = await Deno .readFile (" README.md" );
158
158
await assign (denops , bufnr , content );
159
159
}
@@ -171,7 +171,7 @@ import { assign, open } from "../buffer/mod.ts";
171
171
172
172
export async function main(denops : Denops ): Promise <void > {
173
173
await open (denops , " README.md" );
174
- const bufnr = await fn .bufnr (denops ) as number ;
174
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
175
175
const content = await Deno .readFile (" README.md" );
176
176
// A preprocessor that replace all non words to "-"
177
177
const preprocessor = (repl : string []): string [] => {
@@ -194,7 +194,7 @@ import { concrete, open, replace } from "../buffer/mod.ts";
194
194
195
195
export async function main(denops : Denops ): Promise <void > {
196
196
await open (denops , " README.md" );
197
- const bufnr = await fn .bufnr (denops ) as number ;
197
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
198
198
await fn .setbufvar (denops , bufnr , " &buftype" , " nofile" );
199
199
await replace (denops , bufnr , [" Hello" , " World" ]);
200
200
await concrete (denops , bufnr );
@@ -215,7 +215,7 @@ import { ensure, open } from "../buffer/mod.ts";
215
215
216
216
export async function main(denops : Denops ): Promise <void > {
217
217
await open (denops , " README.md" );
218
- const bufnr = await fn .bufnr (denops ) as number ;
218
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
219
219
// ...
220
220
await ensure (denops , bufnr , async () => {
221
221
await option .buftype .set (denops , " nofile" );
@@ -239,7 +239,7 @@ import { modifiable, open } from "../buffer/mod.ts";
239
239
240
240
export async function main(denops : Denops ): Promise <void > {
241
241
await open (denops , " README.md" );
242
- const bufnr = await fn .bufnr (denops ) as number ;
242
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
243
243
// ...
244
244
await modifiable (denops , bufnr , async () => {
245
245
await fn .setline (denops , 1 , [" Hello" , " World" ]);
@@ -258,7 +258,7 @@ import { decorate, open } from "../buffer/mod.ts";
258
258
259
259
export async function main(denops : Denops ): Promise <void > {
260
260
await open (denops , " README.md" );
261
- const bufnr = await fn .bufnr (denops ) as number ;
261
+ const bufnr = ( await fn .bufnr (denops ) ) as number ;
262
262
// ...
263
263
await decorate (denops , bufnr , [
264
264
{
@@ -277,5 +277,43 @@ export async function main(denops: Denops): Promise<void> {
277
277
}
278
278
```
279
279
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
+
280
318
It uses ` prop_add ` in Vim and ` nvim_buf_add_highlight ` in Neovim to decorate the
281
319
buffer.
0 commit comments