diff options
Diffstat (limited to 'src/nvim/generators/gen_ex_cmds.lua')
-rw-r--r-- | src/nvim/generators/gen_ex_cmds.lua | 81 |
1 files changed, 57 insertions, 24 deletions
diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua index ae8c952648..e8d1aac182 100644 --- a/src/nvim/generators/gen_ex_cmds.lua +++ b/src/nvim/generators/gen_ex_cmds.lua @@ -21,24 +21,32 @@ local a_to_z = byte_z - byte_a + 1 -- Table giving the index of the first command in cmdnames[] to lookup -- based on the first letter of a command. -local cmdidxs1_out = string.format([[ +local cmdidxs1_out = string.format( + [[ static const uint16_t cmdidxs1[%u] = { -]], a_to_z) +]], + a_to_z +) -- Table giving the index of the first command in cmdnames[] to lookup -- based on the first 2 letters of a command. -- Values in cmdidxs2[c1][c2] are relative to cmdidxs1[c1] so that they -- fit in a byte. -local cmdidxs2_out = string.format([[ +local cmdidxs2_out = string.format( + [[ static const uint8_t cmdidxs2[%u][%u] = { /* a b c d e f g h i j k l m n o p q r s t u v w x y z */ -]], a_to_z, a_to_z) +]], + a_to_z, + a_to_z +) enumfile:write([[ // IWYU pragma: private, include "nvim/ex_cmds_defs.h" typedef enum CMD_index { ]]) -defsfile:write(string.format([[ +defsfile:write(string.format( + [[ #include "nvim/arglist.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" @@ -79,23 +87,34 @@ defsfile:write(string.format([[ static const int command_count = %u; static CommandDefinition cmdnames[%u] = { -]], #defs, #defs)) +]], + #defs, + #defs +)) local cmds, cmdidxs1, cmdidxs2 = {}, {}, {} for _, cmd in ipairs(defs) do if bit.band(cmd.flags, flags.RANGE) == flags.RANGE then - assert(cmd.addr_type ~= 'ADDR_NONE', - string.format('ex_cmds.lua:%s: Using RANGE with ADDR_NONE\n', cmd.command)) + assert( + cmd.addr_type ~= 'ADDR_NONE', + string.format('ex_cmds.lua:%s: Using RANGE with ADDR_NONE\n', cmd.command) + ) else - assert(cmd.addr_type == 'ADDR_NONE', - string.format('ex_cmds.lua:%s: Missing ADDR_NONE\n', cmd.command)) + assert( + cmd.addr_type == 'ADDR_NONE', + string.format('ex_cmds.lua:%s: Missing ADDR_NONE\n', cmd.command) + ) end if bit.band(cmd.flags, flags.DFLALL) == flags.DFLALL then - assert(cmd.addr_type ~= 'ADDR_OTHER' and cmd.addr_type ~= 'ADDR_NONE', - string.format('ex_cmds.lua:%s: Missing misplaced DFLALL\n', cmd.command)) + assert( + cmd.addr_type ~= 'ADDR_OTHER' and cmd.addr_type ~= 'ADDR_NONE', + string.format('ex_cmds.lua:%s: Missing misplaced DFLALL\n', cmd.command) + ) end if bit.band(cmd.flags, flags.PREVIEW) == flags.PREVIEW then - assert(cmd.preview_func ~= nil, - string.format('ex_cmds.lua:%s: Missing preview_func\n', cmd.command)) + assert( + cmd.preview_func ~= nil, + string.format('ex_cmds.lua:%s: Missing preview_func\n', cmd.command) + ) end local enumname = cmd.enum or ('CMD_' .. cmd.command) local byte_cmd = cmd.command:sub(1, 1):byte() @@ -104,12 +123,13 @@ for _, cmd in ipairs(defs) do end local preview_func if cmd.preview_func then - preview_func = string.format("&%s", cmd.preview_func) + preview_func = string.format('&%s', cmd.preview_func) else - preview_func = "NULL" + preview_func = 'NULL' end enumfile:write(' ' .. enumname .. ',\n') - defsfile:write(string.format([[ + defsfile:write(string.format( + [[ [%s] = { .cmd_name = "%s", .cmd_func = (ex_func_T)&%s, @@ -117,7 +137,14 @@ for _, cmd in ipairs(defs) do .cmd_argt = %uL, .cmd_addr_type = %s }, -]], enumname, cmd.command, cmd.func, preview_func, cmd.flags, cmd.addr_type)) +]], + enumname, + cmd.command, + cmd.func, + preview_func, + cmd.flags, + cmd.addr_type + )) end for i = #cmds, 1, -1 do local cmd = cmds[i] @@ -141,10 +168,12 @@ for i = byte_a, byte_z do cmdidxs2_out = cmdidxs2_out .. ' /* ' .. c1 .. ' */ {' for j = byte_a, byte_z do local c2 = string.char(j) - cmdidxs2_out = cmdidxs2_out .. - ((cmdidxs2[c1] and cmdidxs2[c1][c2]) - and string.format('%3d', cmdidxs2[c1][c2] - cmdidxs1[c1]) - or ' 0') .. ',' + cmdidxs2_out = cmdidxs2_out + .. ((cmdidxs2[c1] and cmdidxs2[c1][c2]) and string.format( + '%3d', + cmdidxs2[c1][c2] - cmdidxs1[c1] + ) or ' 0') + .. ',' end cmdidxs2_out = cmdidxs2_out .. ' },\n' end @@ -154,8 +183,12 @@ enumfile:write([[ CMD_USER_BUF = -2 } cmdidx_T; ]]) -defsfile:write(string.format([[ +defsfile:write(string.format( + [[ }; %s}; %s}; -]], cmdidxs1_out, cmdidxs2_out)) +]], + cmdidxs1_out, + cmdidxs2_out +)) |