aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_eval_files.lua
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 /scripts/gen_eval_files.lua
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 'scripts/gen_eval_files.lua')
-rwxr-xr-xscripts/gen_eval_files.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua
index edf95043c5..a9431ae2e5 100755
--- a/scripts/gen_eval_files.lua
+++ b/scripts/gen_eval_files.lua
@@ -617,8 +617,8 @@ local function render_option_meta(_f, opt, write)
end
for _, s in pairs {
- { 'wo', 'window' },
- { 'bo', 'buffer' },
+ { 'wo', 'win' },
+ { 'bo', 'buf' },
{ 'go', 'global' },
} do
local id, scope = s[1], s[2]
@@ -661,8 +661,8 @@ end
local function scope_to_doc(s)
local m = {
global = 'global',
- buffer = 'local to buffer',
- window = 'local to window',
+ buf = 'local to buffer',
+ win = 'local to window',
tab = 'local to tab page',
}
@@ -717,7 +717,7 @@ local function get_option_meta()
local optinfo = vim.api.nvim_get_all_options_info()
local ret = {} --- @type table<string,vim.option_meta>
for _, o in ipairs(opts) do
- local is_window_option = #o.scope == 1 and o.scope[1] == 'window'
+ local is_window_option = #o.scope == 1 and o.scope[1] == 'win'
local is_option_hidden = o.immutable and not o.varname and not is_window_option
if not is_option_hidden and o.desc then
if o.full_name == 'cmdheight' then