diff options
author | Famiu Haque <famiuhaque@proton.me> | 2023-12-08 12:36:37 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@proton.me> | 2023-12-10 19:20:28 +0600 |
commit | a34cc1a44de75eff4c6b43f983dc983eb283119d (patch) | |
tree | 0a09f2275d26761914ab861e6522b6b90c761fb7 /src/nvim/generators/gen_options.lua | |
parent | bf3bc1cec9f00b9644815001a8732ecedf3ce07f (diff) | |
download | rneovim-a34cc1a44de75eff4c6b43f983dc983eb283119d.tar.gz rneovim-a34cc1a44de75eff4c6b43f983dc983eb283119d.tar.bz2 rneovim-a34cc1a44de75eff4c6b43f983dc983eb283119d.zip |
refactor(options): define `kOptIndexCount`
Add a macro to indicate the option count so that we can iterate through the options[] table more clearly. This also removes the need for having an option with NULL fullname at the end of `options[]`.
Diffstat (limited to 'src/nvim/generators/gen_options.lua')
-rw-r--r-- | src/nvim/generators/gen_options.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 7c5fc08129..b7356a7bb1 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -44,8 +44,8 @@ local list_flags = { --- @param s string --- @return string -local title_case = function(s) - return s:sub(1, 1):upper() .. s:sub(2):lower() +local lowercase_to_titlecase = function(s) + return s:sub(1, 1):upper() .. s:sub(2) end --- @param o vim.option_meta @@ -229,7 +229,6 @@ static vimoption_T options[] = {]]) for i, o in ipairs(options.options) do dump_option(i, o) end -w(' [' .. ('%u'):format(#options.options) .. ']={.fullname=NULL}') w('};') w('') @@ -242,9 +241,13 @@ opt_fd = assert(io.open(options_enum_file, 'w')) w('typedef enum {') w(' kOptInvalid = -1,') + for i, o in ipairs(options.options) do - w((' kOpt%s = %u,'):format(title_case(o.full_name), i - 1)) + w((' kOpt%s = %u,'):format(lowercase_to_titlecase(o.full_name), i - 1)) end + +w(' // Option count, used when iterating through options') +w('#define kOptIndexCount ' .. tostring(#options.options)) w('} OptIndex;') opt_fd:close() |