diff options
| author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-12-10 16:26:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-10 16:26:08 +0100 |
| commit | 529498685bbcd4783bc0e816d6247118c9ffb9a7 (patch) | |
| tree | 4a907cfe9e6d7cd49d0dd3d60a70550b6598b391 /src/nvim/generators | |
| parent | c675e51c2f3f8bf46457a3f6653af06a2a946f69 (diff) | |
| parent | a34cc1a44de75eff4c6b43f983dc983eb283119d (diff) | |
| download | rneovim-529498685bbcd4783bc0e816d6247118c9ffb9a7.tar.gz rneovim-529498685bbcd4783bc0e816d6247118c9ffb9a7.tar.bz2 rneovim-529498685bbcd4783bc0e816d6247118c9ffb9a7.zip | |
Merge pull request #26458 from famiu/refactor/options/optionindex
Diffstat (limited to 'src/nvim/generators')
| -rw-r--r-- | src/nvim/generators/gen_options.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 3a355634f3..b7356a7bb1 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -1,4 +1,5 @@ local options_file = arg[1] +local options_enum_file = arg[2] local opt_fd = assert(io.open(options_file, 'w')) @@ -41,6 +42,12 @@ local list_flags = { flagscomma = 'P_COMMA|P_FLAGLIST', } +--- @param s string +--- @return string +local lowercase_to_titlecase = function(s) + return s:sub(1, 1):upper() .. s:sub(2) +end + --- @param o vim.option_meta --- @return string local function get_flags(o) @@ -222,11 +229,25 @@ 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('') for _, v in ipairs(defines) do w('#define ' .. v[1] .. ' ' .. v[2]) end + +-- Generate options enum file +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(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() |