@@ -433,6 +433,51 @@ export async function getbufline(
433
433
return await denops . call ( "getbufline" , buf , lnum , end ) as string [ ] ;
434
434
}
435
435
436
+ /**
437
+ * The result is the value of option or local buffer variable
438
+ * **{varname}** in buffer **{buf}**. Note that the name without "b:"
439
+ * must be used.
440
+ * The **{varname}** argument is a string.
441
+ * When **{varname}** is empty returns a `Dictionary` with all the
442
+ * buffer-local variables.
443
+ * When **{varname}** is equal to "&" returns a `Dictionary` with all
444
+ * the buffer-local options.
445
+ * Otherwise, when **{varname}** starts with "&" returns the value of
446
+ * a buffer-local option.
447
+ * This also works for a global or buffer-local option, but it
448
+ * doesn't work for a global variable, window-local variable or
449
+ * window-local option.
450
+ * For the use of **{buf}**, see `bufname()` above.
451
+ * When the buffer or variable doesn't exist **{def}** or an empty
452
+ * string is returned, there is no error message.
453
+ * Examples:
454
+ *
455
+ * :let bufmodified = getbufvar(1, "&mod")
456
+ * :echo "todo myvar = " .. getbufvar("todo", "myvar")
457
+ *
458
+ * Can also be used as a `method`:
459
+ *
460
+ * GetBufnr()->getbufvar(varname)
461
+ */
462
+ export function getbufvar (
463
+ denops : Denops ,
464
+ buf : BufNameArg ,
465
+ varname : "" | "&" ,
466
+ def ?: unknown ,
467
+ ) : Promise < Record < string , unknown > > ;
468
+ export function getbufvar (
469
+ denops : Denops ,
470
+ buf : BufNameArg ,
471
+ varname : string ,
472
+ def ?: unknown ,
473
+ ) : Promise < unknown > ;
474
+ export function getbufvar (
475
+ denops : Denops ,
476
+ ...args : unknown [ ]
477
+ ) : Promise < unknown > {
478
+ return denops . call ( "getbufvar" , ...args ) ;
479
+ }
480
+
436
481
/**
437
482
* Set line **{lnum}** to **{text}** in buffer **{buf}**. This works like
438
483
* `setline()` for the specified buffer.
0 commit comments