diff options
Diffstat (limited to 'src/nvim/generators/gen_unicode_tables.lua')
-rw-r--r-- | src/nvim/generators/gen_unicode_tables.lua | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/nvim/generators/gen_unicode_tables.lua b/src/nvim/generators/gen_unicode_tables.lua index 9ad99c8029..6cedb5db50 100644 --- a/src/nvim/generators/gen_unicode_tables.lua +++ b/src/nvim/generators/gen_unicode_tables.lua @@ -60,12 +60,10 @@ local fp_lines_to_lists = function(fp, n, has_comments) if not line then break end - if (not has_comments - or (line:sub(1, 1) ~= '#' and not line:match('^%s*$'))) then + if not has_comments or (line:sub(1, 1) ~= '#' and not line:match('^%s*$')) then local l = split_on_semicolons(line) if #l ~= n then - io.stderr:write(('Found %s items in line %u, expected %u\n'):format( - #l, i, n)) + io.stderr:write(('Found %s items in line %u, expected %u\n'):format(#l, i, n)) io.stderr:write('Line: ' .. line .. '\n') return nil end @@ -93,15 +91,13 @@ end local make_range = function(start, end_, step, add) if step and add then - return (' {0x%x, 0x%x, %d, %d},\n'):format( - start, end_, step == 0 and -1 or step, add) + return (' {0x%x, 0x%x, %d, %d},\n'):format(start, end_, step == 0 and -1 or step, add) else return (' {0x%04x, 0x%04x},\n'):format(start, end_) end end -local build_convert_table = function(ut_fp, props, cond_func, nl_index, - table_name) +local build_convert_table = function(ut_fp, props, cond_func, nl_index, table_name) ut_fp:write('static const convertStruct ' .. table_name .. '[] = {\n') local start = -1 local end_ = -1 @@ -137,8 +133,7 @@ local build_case_table = function(ut_fp, dataprops, table_name, index) local cond_func = function(p) return p[index] ~= '' end - return build_convert_table(ut_fp, dataprops, cond_func, index, - 'to' .. table_name) + return build_convert_table(ut_fp, dataprops, cond_func, index, 'to' .. table_name) end local build_fold_table = function(ut_fp, foldprops) @@ -154,7 +149,7 @@ local build_combining_table = function(ut_fp, dataprops) local end_ = -1 for _, p in ipairs(dataprops) do -- The 'Mc' property was removed, it does take up space. - if (({Mn=true, Me=true})[p[3]]) then + if ({ Mn = true, Me = true })[p[3]] then local n = tonumber(p[1], 16) if start >= 0 and end_ + 1 == n then -- Continue with the same range. @@ -175,8 +170,7 @@ local build_combining_table = function(ut_fp, dataprops) ut_fp:write('};\n') end -local build_width_table = function(ut_fp, dataprops, widthprops, widths, - table_name) +local build_width_table = function(ut_fp, dataprops, widthprops, widths, table_name) ut_fp:write('static const struct interval ' .. table_name .. '[] = {\n') local start = -1 local end_ = -1 @@ -208,13 +202,13 @@ local build_width_table = function(ut_fp, dataprops, widthprops, widths, -- Only use the char when it’s not a composing char. -- But use all chars from a range. local dp = dataprops[dataidx] - if (n_last > n) or (not (({Mn=true, Mc=true, Me=true})[dp[3]])) then + if (n_last > n) or not ({ Mn = true, Mc = true, Me = true })[dp[3]] then if start >= 0 and end_ + 1 == n then -- luacheck: ignore 542 -- Continue with the same range. else if start >= 0 then ut_fp:write(make_range(start, end_)) - table.insert(ret, {start, end_}) + table.insert(ret, { start, end_ }) end start = n end @@ -224,7 +218,7 @@ local build_width_table = function(ut_fp, dataprops, widthprops, widths, end if start >= 0 then ut_fp:write(make_range(start, end_)) - table.insert(ret, {start, end_}) + table.insert(ret, { start, end_ }) end ut_fp:write('};\n') return ret @@ -316,10 +310,9 @@ local eaw_fp = io.open(eastasianwidth_fname, 'r') local widthprops = parse_width_props(eaw_fp) eaw_fp:close() -local doublewidth = build_width_table(ut_fp, dataprops, widthprops, - {W=true, F=true}, 'doublewidth') -local ambiwidth = build_width_table(ut_fp, dataprops, widthprops, - {A=true}, 'ambiguous') +local doublewidth = + build_width_table(ut_fp, dataprops, widthprops, { W = true, F = true }, 'doublewidth') +local ambiwidth = build_width_table(ut_fp, dataprops, widthprops, { A = true }, 'ambiguous') local emoji_fp = io.open(emoji_fname, 'r') local emojiprops = parse_emoji_props(emoji_fp) |