From 00ae77dc4982a261d1ff939ebb33149f76de437a Mon Sep 17 00:00:00 2001 From: Heyward Fann Date: Fri, 22 Nov 2024 09:50:40 +0800 Subject: [PATCH] feat: override nvim.setOption/getOption https://github.com/neoclide/coc.nvim/pull/5196 --- src/api/Neovim.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api/Neovim.ts b/src/api/Neovim.ts index 0b4d477..28b7d80 100644 --- a/src/api/Neovim.ts +++ b/src/api/Neovim.ts @@ -44,6 +44,21 @@ function getArgs(args?: VimValue | VimValue[]): VimValue[] { export class Neovim extends BaseApi { protected prefix = 'nvim_' + public getOption(name: string): Promise { + const method = this.transport.isVim ? `nvim_get_option` : `nvim_get_option_value` + const args = this.transport.isVim ? [name] : [name, {}] + return this.request(method, args) + } + + public setOption(name: string, value: VimValue): Promise + public setOption(name: string, value: VimValue, isNotify: true): void + public setOption(name: string, value: VimValue, isNotify?: boolean): Promise | void { + const method = this.transport.isVim ? `nvim_set_option` : `nvim_set_option_value` + const args = this.transport.isVim ? [name, value] : [name, value, {}] + + return isNotify ? this.notify(method, args) : this.request(method, args) + } + public get apiInfo(): Promise<[number, ApiInfo]> { return this.request(`${this.prefix}get_api_info`) }