mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
refactor(options): remove getoption_T
and introduce OptVal
(#23850)
Removes the `getoption_T` struct and also introduces the `OptVal` struct to unify the methods of getting/setting different option value types. This is the first of many PRs to reduce code duplication in the Vim option code as well as to make options easier to maintain. It also increases the flexibility and extensibility of options. Which opens the door for things like Array and Dictionary options.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef NVIM_OPTION_DEFS_H
|
||||
#define NVIM_OPTION_DEFS_H
|
||||
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/eval/typval_defs.h"
|
||||
#include "nvim/macros.h"
|
||||
#include "nvim/types.h"
|
||||
@@ -1080,4 +1081,24 @@ typedef struct vimoption {
|
||||
// buffers. Indicate this by setting "var" to VAR_WIN.
|
||||
#define VAR_WIN ((char *)-1)
|
||||
|
||||
// Option value type
|
||||
typedef enum {
|
||||
kOptValTypeNil = 0,
|
||||
kOptValTypeBoolean,
|
||||
kOptValTypeNumber,
|
||||
kOptValTypeString,
|
||||
} OptValType;
|
||||
|
||||
// Option value
|
||||
typedef struct {
|
||||
OptValType type;
|
||||
|
||||
union {
|
||||
// Vim boolean options are actually tri-states because they have a third "None" value.
|
||||
TriState boolean;
|
||||
Integer number;
|
||||
String string;
|
||||
} data;
|
||||
} OptVal;
|
||||
|
||||
#endif // NVIM_OPTION_DEFS_H
|
||||
|
Reference in New Issue
Block a user