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:
Famiu Haque
2023-06-07 06:05:16 +06:00
committed by GitHub
parent 0370e4def0
commit b3d5138fd0
29 changed files with 683 additions and 378 deletions

View File

@@ -910,10 +910,10 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
if (scratch) {
aco_save_T aco;
aucmd_prepbuf(&aco, buf);
set_option_value("bufhidden", 0L, "hide", OPT_LOCAL);
set_option_value("buftype", 0L, "nofile", OPT_LOCAL);
set_option_value("swapfile", 0L, NULL, OPT_LOCAL);
set_option_value("modeline", 0L, NULL, OPT_LOCAL); // 'nomodeline'
set_option_value("bufhidden", STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL);
set_option_value("buftype", STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL);
set_option_value("swapfile", BOOLEAN_OPTVAL(false), OPT_LOCAL);
set_option_value("modeline", BOOLEAN_OPTVAL(false), OPT_LOCAL); // 'nomodeline'
aucmd_restbuf(&aco);
}
return buf->b_fnum;