Skip to content

Commit 5766d60

Browse files
committed
nvim: add AllOptionsInfo and OptionInfo
1 parent 6682528 commit 5766d60

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

nvim/apidef.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,75 @@ func SetVVar(name string, value interface{}) {
570570
name(nvim_set_vvar)
571571
}
572572

573+
// AllOptionsInfo gets the option information for all options.
574+
//
575+
// The dictionary has the full option names as keys and option metadata
576+
// dictionaries as detailed at `nvim_get_option_info`.
577+
//
578+
// Resulting map has keys:
579+
//
580+
// name
581+
// Name of the option (like 'filetype').
582+
// shortname
583+
// Shortened name of the option (like 'ft').
584+
// type
585+
// type of option ("string", "integer" or "boolean").
586+
// default
587+
// The default value for the option.
588+
// was_set
589+
// Whether the option was set.
590+
// last_set_sid
591+
// Last set script id (if any).
592+
// last_set_linenr
593+
// line number where option was set.
594+
// last_set_chan
595+
// Channel where option was set (0 for local).
596+
// scope
597+
// one of "global", "win", or "buf".
598+
// global_local
599+
// whether win or buf option has a global value.
600+
// commalist
601+
// List of comma separated values.
602+
// flaglist
603+
// List of single char flags.
604+
func AllOptionsInfo() OptionInfo {
605+
name(nvim_get_all_options_info)
606+
returnPtr()
607+
}
608+
609+
// OptionInfo Gets the option information for one option.
610+
//
611+
// Resulting dictionary has keys:
612+
//
613+
// name
614+
// Name of the option (like 'filetype').
615+
// shortname
616+
// Shortened name of the option (like 'ft').
617+
// type
618+
// type of option ("string", "integer" or "boolean").
619+
// default
620+
// The default value for the option.
621+
// was_set
622+
// Whether the option was set.
623+
// last_set_sid
624+
// Last set script id (if any).
625+
// last_set_linenr
626+
// line number where option was set.
627+
// last_set_chan
628+
// Channel where option was set (0 for local).
629+
// scope
630+
// one of "global", "win", or "buf".
631+
// global_local
632+
// whether win or buf option has a global value.
633+
// commalist
634+
// List of comma separated values.
635+
// flaglist
636+
// List of single char flags.
637+
func OptionInfo(name string) OptionInfo {
638+
name(nvim_get_option_info)
639+
returnPtr()
640+
}
641+
573642
// Option gets an option.
574643
func Option(name string) interface{} {
575644
name(nvim_get_option)

nvim/apitool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ var nvimTypes = map[string]string{
307307
"map[string]int": "Dictionary",
308308
"map[string]interface{}": "Dictionary",
309309
"Mode": "Dictionary",
310+
"OptionInfo": "Dictionary",
310311

311312
"[]*Channel": "Array",
312313
"[]*Process": "Array",

nvim/types.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,42 @@ type ExtMarks struct {
299299
Row int
300300
Col int
301301
}
302+
303+
// OptionInfo represents a option information.
304+
type OptionInfo struct {
305+
// Name is the name of the option (like 'filetype').
306+
Name string `msgpack:"name"`
307+
308+
// ShortName is the shortened name of the option (like 'ft').
309+
ShortName string `msgpack:"shortname"`
310+
311+
// Type is the type of option ("string", "number" or "boolean").
312+
Type string `msgpack:"type"`
313+
314+
// Default is the default value for the option.
315+
Default interface{} `msgpack:"default"`
316+
317+
// WasSet whether the option was set.
318+
WasSet bool `msgpack:"was_set"`
319+
320+
// LastSetSid is the last set script id (if any).
321+
LastSetSid int `msgpack:"last_set_sid"`
322+
323+
// LastSetLinenr is the line number where option was set.
324+
LastSetLinenr int `msgpack:"last_set_linenr"`
325+
326+
// LastSetChan is the channel where option was set (0 for local).
327+
LastSetChan int `msgpack:"last_set_chan"`
328+
329+
// Scope one of "global", "win", or "buf".
330+
Scope string `msgpack:"scope"`
331+
332+
// GlobalLocal whether win or buf option has a global value.
333+
GlobalLocal bool `msgpack:"global_local"`
334+
335+
// CommaList whether the list of comma separated values.
336+
CommaList bool `msgpack:"commalist"`
337+
338+
// FlagList whether the list of single char flags.
339+
FlagList bool `msgpack:"flaglist"`
340+
}

0 commit comments

Comments
 (0)