Skip to content

Config structure

Alexander Makarov edited this page Jan 6, 2023 · 3 revisions

Config structure can be described with following type declarations:

class Node extends Opts, { [Lhs]: NodeF }, { [integer]: NodeF } {
  act?: Act,
  name?: string,
  mode?: Mode | Mode[],
  mode_extend?: Mode | Mode[],
  when?: RelaxedEventDescription | RelaxedEventDescription[],
  when_extend?: RelaxedEventDescription | RelaxedEventDescription[],

  // deprecated:
  buf_local?: RelaxedEventDescription | RelaxedEventDescription[],
  buf_local_extend?: RelaxedEventDescription | RelaxedEventDescription[],
}

type NodeF = Node | function(): Node

type Mode = string

type Act = Rhs | { [Mode]: Rhs }

type Lhs = string

type Rhs = string | function

class Opts {
  desc?: string,
  expr?: boolean,
  noremap?: boolen,
  nowait?: boolean,
  silent?: boolean,
  unique?: boolean,
  buffer?: integer,
}

type RelaxedEventDescription = string | EventDescription

class EventDescription {
  event: string | string[],
  pattern?: string | string[],
  group?: string,
  condition?: function(event: VimEvent): boolean,
}
Clone this wiki locally