Skip to content

Commit 73cbff8

Browse files
committed
👍 Add setbufvar() to buffer-function
1 parent 5889afc commit 73cbff8

File tree

2 files changed

+30
-34
lines changed

2 files changed

+30
-34
lines changed

denops_std/function/_generated.ts

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

denops_std/function/buffer.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,33 @@ export async function setbufline(
575575
const result = await denops.call("setbufline", buf, lnum, text) as number;
576576
return !!result;
577577
}
578+
579+
/**
580+
* Set option or local variable **{varname}** in buffer **{buf}** to
581+
* **{val}**.
582+
* This also works for a global or local window option, but it
583+
* doesn't work for a global or local window variable.
584+
* For a local window option the global value is unchanged.
585+
* For the use of **{buf}**, see `bufname()` above.
586+
* The **{varname}** argument is a string.
587+
* Note that the variable name without "b:" must be used.
588+
* Examples:
589+
*
590+
* :call setbufvar(1, "&mod", 1)
591+
* :call setbufvar("todo", "myvar", "foobar")
592+
*
593+
* This function is not available in the `sandbox`.
594+
*
595+
* Can also be used as a `method`, the base is passed as the
596+
* third argument:
597+
*
598+
* GetValue()->setbufvar(buf, varname)
599+
*/
600+
export async function setbufvar(
601+
denops: Denops,
602+
buf: BufNameArg,
603+
varname: string,
604+
val: unknown,
605+
): Promise<void> {
606+
await denops.call("setbufvar", buf, varname, val);
607+
}

0 commit comments

Comments
 (0)