aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option_defs.h
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@protonmail.com>2022-09-27 21:16:28 +0600
committerFamiu Haque <famiuhaque@protonmail.com>2022-09-28 09:29:43 +0600
commit4b7904d16b11915b16ea46b96f1ea6e28d87d5fd (patch)
treef57971615622d4ae3f6d289da8fcb6730f8a28f1 /src/nvim/option_defs.h
parent1d337d4e2f2265b13ecf19a3bc17ad302d3b0d96 (diff)
downloadrneovim-4b7904d16b11915b16ea46b96f1ea6e28d87d5fd.tar.gz
rneovim-4b7904d16b11915b16ea46b96f1ea6e28d87d5fd.tar.bz2
rneovim-4b7904d16b11915b16ea46b96f1ea6e28d87d5fd.zip
refactor: replace unnecessary helper functions in optionstr.c
Replaces unnecessary helper functions in `optionstr.c` such as `get_option_flags()`, `get_option_fullname()`, `set_option_flag()`, `is_global_option()`, etc. with a single `get_option()` helper function that allows direct access to the `options` array. Also refactors `f_exists()` to use `get_varp_scope` instead of using `get_option_tv`. This opens up the path for removing `getoptions_T` altogether later down the line since the hidden option logic is no longer needed.
Diffstat (limited to 'src/nvim/option_defs.h')
-rw-r--r--src/nvim/option_defs.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index e8cf338cf1..e27607d7a8 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -990,4 +990,41 @@ typedef struct {
uint64_t channel_id; /// Only used when script_id is SID_API_CLIENT.
} LastSet;
+// WV_ and BV_ values get typecasted to this for the "indir" field
+typedef enum {
+ PV_NONE = 0,
+ PV_MAXVAL = 0xffff, // to avoid warnings for value out of range
+} idopt_T;
+
+typedef struct vimoption {
+ char *fullname; // full option name
+ char *shortname; // permissible abbreviation
+ uint32_t flags; // see below
+ char_u *var; // global option: pointer to variable;
+ // window-local option: VAR_WIN;
+ // buffer-local option: global value
+ idopt_T indir; // global option: PV_NONE;
+ // local option: indirect option index
+ char *def_val; // default values for variable (neovim!!)
+ LastSet last_set; // script in which the option was last set
+} vimoption_T;
+
+// The options that are local to a window or buffer have "indir" set to one of
+// these values. Special values:
+// PV_NONE: global option.
+// PV_WIN is added: window-local option
+// PV_BUF is added: buffer-local option
+// PV_BOTH is added: global option which also has a local value.
+#define PV_BOTH 0x1000
+#define PV_WIN 0x2000
+#define PV_BUF 0x4000
+#define PV_MASK 0x0fff
+#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
+#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
+#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
+
+// Options local to a window have a value local to a buffer and global to all
+// buffers. Indicate this by setting "var" to VAR_WIN.
+#define VAR_WIN ((char_u *)-1)
+
#endif // NVIM_OPTION_DEFS_H