aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2024-11-17 02:56:16 +0600
committerGitHub <noreply@github.com>2024-11-16 12:56:16 -0800
commit29ded889579a9d590e8ea885a9a402ff4bae87be (patch)
tree476bc3746cfac48f141e5ab0aaf562480502fad2 /src/nvim/api/vim.c
parentbe8648f345aed5e403251990721918c8302be760 (diff)
downloadrneovim-29ded889579a9d590e8ea885a9a402ff4bae87be.tar.gz
rneovim-29ded889579a9d590e8ea885a9a402ff4bae87be.tar.bz2
rneovim-29ded889579a9d590e8ea885a9a402ff4bae87be.zip
refactor(options): remove `.indir`, redesign option scopes #31066
Problem: The way option scopes currently work is inflexible and does not allow for nested option scopes or easily finding the value of an option at any arbitrary scope without having to do long handwritten switch-case statements like in `get_varp()`. `.indir` is also confusing and redundant since option indices for each scope can be autogenerated. Solution: Expand option scopes in such a way that an option can support any amount of scopes using a set of scope flags, similarly to how it's already done for option types. Also make options contain information about its index at each scope it supports. This allows for massively simplifying `get_varp()` and `get_varp_scope()` in the future by just using a struct for options at each scope. This would be done by creating a table that stores the offset of an option's variable at a scope by using the option's index at that scope as a key. This PR also autogenerates enums for option indices at each scope to remove the need for `.indir` entirely, and also to allow easily iterating over options all options that support any scope. Ref: #29314
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index e6ec88c5e8..199b9a9690 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1004,10 +1004,10 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
buf_copy_options(buf, BCO_ENTER | BCO_NOHELP);
if (scratch) {
- set_option_direct_for(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL, 0, kOptReqBuf,
- buf);
- set_option_direct_for(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL, 0, kOptReqBuf,
- buf);
+ set_option_direct_for(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL, 0,
+ kOptScopeBuf, buf);
+ set_option_direct_for(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL, 0,
+ kOptScopeBuf, buf);
assert(buf->b_ml.ml_mfp->mf_fd < 0); // ml_open() should not have opened swapfile already
buf->b_p_swf = false;
buf->b_p_ml = false;