Skip to content

Commit

Permalink
feat: override nvim.setOption/getOption
Browse files Browse the repository at this point in the history
  • Loading branch information
fannheyward committed Nov 22, 2024
1 parent 3bd2606 commit 00ae77d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/api/Neovim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ function getArgs(args?: VimValue | VimValue[]): VimValue[] {
export class Neovim extends BaseApi {
protected prefix = 'nvim_'

public getOption(name: string): Promise<VimValue> {
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<void>
public setOption(name: string, value: VimValue, isNotify: true): void
public setOption(name: string, value: VimValue, isNotify?: boolean): Promise<void> | 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`)
}
Expand Down

0 comments on commit 00ae77d

Please sign in to comment.