From bb6190bec5f18c1f9e2c1d29ef1f7cf7912ea625 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 1 Jun 2024 08:19:41 -0700 Subject: refactor: move shared messages to errors.h #26214 --- src/nvim/generators/gen_api_dispatch.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 62c99ce082..61c80a3d2e 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -306,6 +306,7 @@ local keysets_defs = assert(io.open(keysets_outputf, 'wb')) -- so that the dispatcher can find the C functions that you are creating! -- =========================================================================== output:write([[ +#include "nvim/errors.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/globals.h" -- cgit From 8cbb1f20e557461c8417583a7f69d53aaaef920b Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Tue, 4 Jun 2024 09:06:02 -0400 Subject: refactor(lua): use tuple syntax everywhere #29111 --- src/nvim/generators/gen_options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 0718d965c6..591a6b93df 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -148,7 +148,7 @@ local get_defaults = function(d, n) return value_dumpers[type(d)](d) end ---- @type {[1]:string,[2]:string}[] +--- @type [string,string][] local defines = {} --- @param i integer -- cgit From b66106a46c5c6180c7f80852a8c822b400e73100 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Tue, 4 Jun 2024 15:09:12 +0200 Subject: fix(ui): superfluous showmode / excessive grid_cursor_goto #29089 Problem: Unsetting global variables earlier in #28578 to avoid recursiveness, caused superfluous or even unlimited showmode(). Solution: Partly revert #28578 so that the globals are unset at the end of showmode(), and avoid recursiveness for ext UI by adding a recursive function guard to each generated UI call that may call a Lua callback. --- src/nvim/generators/gen_api_ui_events.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index 516b5ad5ae..c5b37672bf 100644 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -128,8 +128,16 @@ for i = 1, #events do write_signature(call_output, ev, '') call_output:write('\n{\n') if ev.remote_only then + -- Lua callbacks may emit other events or the same event again. Avoid the latter + -- by adding a recursion guard to each generated function that may call a Lua callback. + call_output:write(' static bool entered = false;\n') + call_output:write(' if (entered) {\n') + call_output:write(' return;\n') + call_output:write(' }\n') + call_output:write(' entered = true;\n') write_arglist(call_output, ev) call_output:write(' ui_call_event("' .. ev.name .. '", ' .. args .. ');\n') + call_output:write(' entered = false;\n') elseif ev.compositor_impl then call_output:write(' ui_comp_' .. ev.name) write_signature(call_output, ev, '', true) -- cgit From 496091b63241f33dffc15411e35e89d8018e6fa2 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 12 Jun 2024 21:14:03 +0200 Subject: refactor: replace utf_convert with utf8proc conversion functions --- src/nvim/generators/gen_unicode_tables.lua | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_unicode_tables.lua b/src/nvim/generators/gen_unicode_tables.lua index 6cedb5db50..305b64b7be 100644 --- a/src/nvim/generators/gen_unicode_tables.lua +++ b/src/nvim/generators/gen_unicode_tables.lua @@ -5,13 +5,13 @@ -- (A) east asian width respectively. -- 2. combining table: same as the above, but characters inside are combining -- characters (i.e. have general categories equal to Mn, Mc or Me). --- 3. foldCase, toLower and toUpper tables used to convert characters to --- folded/lower/upper variants. In these tables first two values are +-- 3. foldCase table used to convert characters to +-- folded variants. In this table first two values are -- character ranges: like in previous tables they are sorted and must be -- non-overlapping. Third value means step inside the range: e.g. if it is -- 2 then interval applies only to first, third, fifth, … character in range. -- Fourth value is number that should be added to the codepoint to yield --- folded/lower/upper codepoint. +-- folded codepoint. -- 4. emoji_wide and emoji_all tables: sorted lists of non-overlapping closed -- intervals of Emoji characters. emoji_wide contains all the characters -- which don't have ambiguous or double width, and emoji_all has all Emojis. @@ -129,13 +129,6 @@ local build_convert_table = function(ut_fp, props, cond_func, nl_index, table_na ut_fp:write('};\n') end -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) -end - local build_fold_table = function(ut_fp, foldprops) local cond_func = function(p) return (p[2] == 'C' or p[2] == 'S') @@ -296,8 +289,6 @@ ud_fp:close() local ut_fp = io.open(utf_tables_fname, 'w') -build_case_table(ut_fp, dataprops, 'Lower', 14) -build_case_table(ut_fp, dataprops, 'Upper', 13) build_combining_table(ut_fp, dataprops) local cf_fp = io.open(casefolding_fname, 'r') -- cgit From 7dffc36e61c46e6adc92cff5944e876446f3c40e Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 13 Jun 2024 12:00:58 +0200 Subject: refactor(declarations): also generate prototypes for functions in headers Before this change, "static inline" functions in headers needed to have their function attributes specified in a completely different way. The prototype had to be duplicated, and REAL_FATTR_ had to be used instead of the public FUNC_ATTR_ names. TODO: need a check that a "header.h.inline.generated.h" file is not forgotten when the first "static inline" function with attributes is added to a header (they would just be silently missing). --- src/nvim/generators/gen_declarations.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index 5d1e586fe6..3bba0aa4b9 100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -2,6 +2,7 @@ local fname = arg[1] local static_fname = arg[2] local non_static_fname = arg[3] local preproc_fname = arg[4] +local static_basename = arg[5] local lpeg = vim.lpeg @@ -235,6 +236,7 @@ local declendpos = 0 local curdir = nil local is_needed_file = false local init_is_nl = true +local any_static = false while init ~= nil do if init_is_nl and text:sub(init, init) == '#' then local line, dir, file = text:match(filepattern, init) @@ -276,6 +278,9 @@ while init ~= nil do end declaration = declaration .. '\n' if declaration:sub(1, 6) == 'static' then + if declaration:find('FUNC_ATTR_') then + any_static = true + end static = static .. declaration else declaration = 'DLLEXPORT ' .. declaration @@ -303,6 +308,18 @@ F = io.open(static_fname, 'w') F:write(static) F:close() +if non_static_fname == 'SKIP' then + F = io.open(fname, 'r') + if any_static then + local orig_text = F:read('*a') + local pat = '\n#%s?include%s+"' .. static_basename .. '"\n' + if not string.find(orig_text, pat) then + error('fail: missing include for ' .. static_basename .. ' in ' .. fname) + end + end + return -- only want static declarations +end + -- Before generating the non-static headers, check if the current file (if -- exists) is different from the new one. If they are the same, we won't touch -- the current version to avoid triggering an unnecessary rebuilds of modules -- cgit From b213f5169c33357d03012c52306789fd81a35b60 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Jul 2024 06:08:16 +0800 Subject: build: allow comment after #include for required header (#29722) And also check in .c files, as the attributes may be silently missing there as well. --- src/nvim/generators/gen_declarations.lua | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index 3bba0aa4b9..f4d1d19481 100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -208,6 +208,10 @@ if fname:find('.*/src/nvim/.*%.c$') then // IWYU pragma: private, include "%s" ]]):format(header_fname:gsub('.*/src/nvim/', 'nvim/')) .. non_static end +elseif fname:find('.*/src/nvim/.*%.h$') then + static = ([[ +// IWYU pragma: private, include "%s" +]]):format(fname:gsub('.*/src/nvim/', 'nvim/')) .. static elseif non_static_fname:find('/include/api/private/dispatch_wrappers%.h%.generated%.h$') then non_static = [[ // IWYU pragma: private, include "nvim/api/private/dispatch.h" @@ -308,15 +312,18 @@ F = io.open(static_fname, 'w') F:write(static) F:close() -if non_static_fname == 'SKIP' then +if any_static then F = io.open(fname, 'r') - if any_static then - local orig_text = F:read('*a') - local pat = '\n#%s?include%s+"' .. static_basename .. '"\n' - if not string.find(orig_text, pat) then - error('fail: missing include for ' .. static_basename .. ' in ' .. fname) - end + local orig_text = F:read('*a') + local pat = '\n#%s?include%s+"' .. static_basename .. '"\n' + local pat_comment = '\n#%s?include%s+"' .. static_basename .. '"%s*//' + if not string.find(orig_text, pat) and not string.find(orig_text, pat_comment) then + error('fail: missing include for ' .. static_basename .. ' in ' .. fname) end + F:close() +end + +if non_static_fname == 'SKIP' then return -- only want static declarations end @@ -329,7 +336,7 @@ if F ~= nil then if F:read('*a') == non_static then os.exit(0) end - io.close(F) + F:close() end F = io.open(non_static_fname, 'w') -- cgit From 0cdeb06db0062951f2f2d2998510e2fff7e0faee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 25 Jul 2024 09:55:59 +0800 Subject: vim-patch:ddbb6fe: runtime(vim): Update base-syntax, improve :set highlighting (#29850) - Match bang, "all" and "termcap" options, and trailing command separator "|". - Highlight set assignment operators. - Match multiline :set and multiline option values. - Mention the newer "0o" octal prefix at :help :set=. closes: vim/vim#15329 https://github.com/vim/vim/commit/ddbb6fe2d0344e93436c5602b7a06169f49a9b52 Co-authored-by: Doug Kearns --- src/nvim/generators/gen_vimvim.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_vimvim.lua b/src/nvim/generators/gen_vimvim.lua index fcdc5bddc2..0675f04b73 100644 --- a/src/nvim/generators/gen_vimvim.lua +++ b/src/nvim/generators/gen_vimvim.lua @@ -80,12 +80,13 @@ for _, cmd_desc in ipairs(ex_cmds.cmds) do end local vimopt_start = 'syn keyword vimOption contained ' +local vimopt_end = ' skipwhite nextgroup=vimSetEqual,vimSetMod' w('\n\n' .. vimopt_start) for _, opt_desc in ipairs(options.options) do if not opt_desc.immutable then if lld.line_length > 850 then - w('\n' .. vimopt_start) + w(vimopt_end .. '\n' .. vimopt_start) end w(' ' .. opt_desc.full_name) if opt_desc.abbreviation then @@ -102,7 +103,9 @@ for _, opt_desc in ipairs(options.options) do end end -w('\n\nsyn case ignore') +w(vimopt_end .. '\n') + +w('\nsyn case ignore') local vimau_start = 'syn keyword vimAutoEvent contained ' w('\n\n' .. vimau_start) -- cgit From f926cc32c9262b6254e2843276b951cef9da1afe Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 2 Jul 2024 13:45:50 +0200 Subject: refactor(shada): rework msgpack decoding without msgpack-c This also makes shada reading slightly faster due to avoiding some copying and allocation. Use keysets to drive decoding of msgpack maps for shada entries. --- src/nvim/generators/c_grammar.lua | 6 ++++-- src/nvim/generators/gen_api_dispatch.lua | 27 +++++++++++---------------- src/nvim/generators/hashy.lua | 22 ++++++++++++++++------ 3 files changed, 31 insertions(+), 24 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua index 9ce9f3d7a6..4e7de7adb4 100644 --- a/src/nvim/generators/c_grammar.lua +++ b/src/nvim/generators/c_grammar.lua @@ -91,7 +91,9 @@ local c_proto = Ct( * (P(';') + (P('{') * nl + (impl_line ^ 0) * P('}'))) ) -local c_field = Ct(Cg(c_id, 'type') * ws * Cg(c_id, 'name') * fill * P(';') * fill) +local dict_key = P('DictKey(') * Cg(rep1(any - P(')')), 'dict_key') * P(')') +local keyset_field = + Ct(Cg(c_id, 'type') * ws * Cg(c_id, 'name') * fill * (dict_key ^ -1) * fill * P(';') * fill) local c_keyset = Ct( P('typedef') * ws @@ -99,7 +101,7 @@ local c_keyset = Ct( * fill * P('{') * fill - * Cg(Ct(c_field ^ 1), 'fields') + * Cg(Ct(keyset_field ^ 1), 'fields') * P('}') * fill * P('Dict') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 61c80a3d2e..3567831c41 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -72,14 +72,19 @@ local keysets = {} local function add_keyset(val) local keys = {} local types = {} + local c_names = {} local is_set_name = 'is_set__' .. val.keyset_name .. '_' local has_optional = false for i, field in ipairs(val.fields) do + local dict_key = field.dict_key or field.name if field.type ~= 'Object' then - types[field.name] = field.type + types[dict_key] = field.type end if field.name ~= is_set_name and field.type ~= 'OptionalKeys' then - table.insert(keys, field.name) + table.insert(keys, dict_key) + if dict_key ~= field.name then + c_names[dict_key] = field.name + end else if i > 1 then error("'is_set__{type}_' must be first if present") @@ -94,6 +99,7 @@ local function add_keyset(val) table.insert(keysets, { name = val.keyset_name, keys = keys, + c_names = c_names, types = types, has_optional = has_optional, }) @@ -332,19 +338,6 @@ output:write([[ keysets_defs:write('// IWYU pragma: private, include "nvim/api/private/dispatch.h"\n\n') for _, k in ipairs(keysets) do - local c_name = {} - - for i = 1, #k.keys do - -- some keys, like "register" are c keywords and get - -- escaped with a trailing _ in the struct. - if vim.endswith(k.keys[i], '_') then - local orig = k.keys[i] - k.keys[i] = string.sub(k.keys[i], 1, #k.keys[i] - 1) - c_name[k.keys[i]] = orig - k.types[k.keys[i]] = k.types[orig] - end - end - local neworder, hashfun = hashy.hashy_hash(k.name, k.keys, function(idx) return k.name .. '_table[' .. idx .. '].str' end) @@ -354,6 +347,8 @@ for _, k in ipairs(keysets) do local function typename(type) if type == 'HLGroupID' then return 'kObjectTypeInteger' + elseif type == 'StringArray' then + return 'kUnpackTypeStringArray' elseif type ~= nil then return 'kObjectType' .. type else @@ -374,7 +369,7 @@ for _, k in ipairs(keysets) do .. '", offsetof(KeyDict_' .. k.name .. ', ' - .. (c_name[key] or key) + .. (k.c_names[key] or key) .. '), ' .. typename(k.types[key]) .. ', ' diff --git a/src/nvim/generators/hashy.lua b/src/nvim/generators/hashy.lua index 711e695742..ea35064962 100644 --- a/src/nvim/generators/hashy.lua +++ b/src/nvim/generators/hashy.lua @@ -73,11 +73,15 @@ function M.switcher(put, tab, maxlen, worst_buck_size) vim.list_extend(neworder, buck) local endidx = #neworder put(" case '" .. c .. "': ") - put('low = ' .. startidx .. '; ') - if bucky then - put('high = ' .. endidx .. '; ') + if len == 1 then + put('return ' .. startidx .. ';\n') + else + put('low = ' .. startidx .. '; ') + if bucky then + put('high = ' .. endidx .. '; ') + end + put 'break;\n' end - put 'break;\n' end put ' default: break;\n' put ' }\n ' @@ -105,13 +109,19 @@ function M.hashy_hash(name, strings, access) end local len_pos_buckets, maxlen, worst_buck_size = M.build_pos_hash(strings) put('int ' .. name .. '_hash(const char *str, size_t len)\n{\n') - if worst_buck_size > 1 then + if maxlen == 1 then + put('\n') -- nothing + elseif worst_buck_size > 1 then put(' int low = 0, high = 0;\n') else put(' int low = -1;\n') end local neworder = M.switcher(put, len_pos_buckets, maxlen, worst_buck_size) - if worst_buck_size > 1 then + if maxlen == 1 then + put([[ + return -1; +]]) + elseif worst_buck_size > 1 then put([[ for (int i = low; i < high; i++) { if (!memcmp(str, ]] .. access('i') .. [[, len)) { -- cgit From b5f92c4e5c7428fe1c1f91620f4b545b30b49855 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Aug 2024 20:13:07 +0800 Subject: refactor: extract eval/fs.c from eval/funcs.c (#29985) In Vim a lot of filesystem functions have been moved to filepath.c. However, some of these functions actually deal with file contents, and Nvim's filesystem-related functions are spread out in a different way. Therefore, it's better to use a different file for these functions. --- src/nvim/generators/gen_eval.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua index 1ce7f1af9d..443c68e008 100644 --- a/src/nvim/generators/gen_eval.lua +++ b/src/nvim/generators/gen_eval.lua @@ -19,6 +19,7 @@ hashpipe:write([[ #include "nvim/digraph.h" #include "nvim/eval.h" #include "nvim/eval/buffer.h" +#include "nvim/eval/fs.h" #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" #include "nvim/eval/vars.h" -- cgit From 328ea02eb7dec32286ae6c691ecef71d988c905b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 18 Jun 2024 14:01:20 +0200 Subject: refactor!: use utf8proc full casefolding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to `CaseFolding-15.1.0.txt`, full casefolding should be preferred over simple casefolding as it's considered to be more correct. Since utf8proc already provides full casefolding it makes sense to switch to it. This will also remove a lot of unnecessary build code. Temporary exceptions are made for two sets characters: - `ß` will still be considered `ß` (instead of `ss`) as using a full casefolding requires interfering with upstream spell files in some form. - `İ` will still be considered `İ` (instead of `i̇`) as using full casefolding requires making a value judgement on the "correct" behavior. There are two, equally valid case-insensetive comparison for this character according to unicode. It is essentially up to the implementor to decide which conversion is correct. For this reason it might make sense to allow users to decide which conversion should be done as an added option to `casemap` in a future PR. --- src/nvim/generators/gen_unicode_tables.lua | 50 ------------------------------ 1 file changed, 50 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_unicode_tables.lua b/src/nvim/generators/gen_unicode_tables.lua index 305b64b7be..01eb34be88 100644 --- a/src/nvim/generators/gen_unicode_tables.lua +++ b/src/nvim/generators/gen_unicode_tables.lua @@ -28,7 +28,6 @@ local get_path = function(fname) end local unicodedata_fname = get_path('UnicodeData.txt') -local casefolding_fname = get_path('CaseFolding.txt') local eastasianwidth_fname = get_path('EastAsianWidth.txt') local emoji_fname = get_path('emoji-data.txt') @@ -77,10 +76,6 @@ local parse_data_to_props = function(ud_fp) return fp_lines_to_lists(ud_fp, 15, false) end -local parse_fold_props = function(cf_fp) - return fp_lines_to_lists(cf_fp, 4, true) -end - local parse_width_props = function(eaw_fp) return fp_lines_to_lists(eaw_fp, 2, true) end @@ -97,45 +92,6 @@ local make_range = function(start, end_, step, add) end end -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 - local step = 0 - local add = -1 - for _, p in ipairs(props) do - if cond_func(p) then - local n = tonumber(p[1], 16) - local nl = tonumber(p[nl_index], 16) - if start >= 0 and add == (nl - n) and (step == 0 or n - end_ == step) then - -- Continue with the same range. - step = n - end_ - end_ = n - else - if start >= 0 then - -- Produce previous range. - ut_fp:write(make_range(start, end_, step, add)) - end - start = n - end_ = n - step = 0 - add = nl - n - end - end - end - if start >= 0 then - ut_fp:write(make_range(start, end_, step, add)) - end - ut_fp:write('};\n') -end - -local build_fold_table = function(ut_fp, foldprops) - local cond_func = function(p) - return (p[2] == 'C' or p[2] == 'S') - end - return build_convert_table(ut_fp, foldprops, cond_func, 3, 'foldCase') -end - local build_combining_table = function(ut_fp, dataprops) ut_fp:write('static const struct interval combining[] = {\n') local start = -1 @@ -291,12 +247,6 @@ local ut_fp = io.open(utf_tables_fname, 'w') build_combining_table(ut_fp, dataprops) -local cf_fp = io.open(casefolding_fname, 'r') -local foldprops = parse_fold_props(cf_fp) -cf_fp:close() - -build_fold_table(ut_fp, foldprops) - local eaw_fp = io.open(eastasianwidth_fname, 'r') local widthprops = parse_width_props(eaw_fp) eaw_fp:close() -- cgit From 26be6446e5ea1c5b22c50bfd9a0e5aa85927aff9 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 14 Aug 2024 10:10:54 +0200 Subject: refactor(multibyte): replace generated unicode tables with utf8proc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit intentionally aims at preserving existing behavior as much as possible while replacing our build step to convert unicode data files into binary tables, which corresponding lookups in utf8proc. Actual improvements in behavior will be a followup. The only change in behavior is that 'emoji' option will turn some more codepoints into double with. Nvim used the "Emoji" and "Emoji_Presentation" properties to define emojis, while utf8proc only exposes the Extended_Pictographic property from the emoji table. This is a superset of the previous emoji properties. As only codepoints above 0x1f000 are affected by the 'emoji' option, this means that the following chars are now treated as double-width, instead of single-width like in previous nvim versions: 🀀 🀁 🀂 🀃 🀅 🀆 🀇 🀈 🀉 🀊 🀋 🀌 🀍 🀎 🀏 🀐 🀑 🀒 🀓 🀔 🀕 🀖 🀗 🀘 🀙 🀚 🀛 🀜 🀝 🀞 🀟 🀠 🀡 🀢 🀣 🀤 🀥 🀦 🀧 🀨 🀩 🀪 🀫 🀰 🀱 🀲 🀳 🀴 🀵 🀶 🀷 🀸 🀹 🀺 🀻 🀼 🀽 🀾 🀿 🁀 🁁 🁂 🁃 🁄 🁅 🁆 🁇 🁈 🁉 🁊 🁋 🁌 🁍 🁎 🁏 🁐 🁑 🁒 🁓 🁔 🁕 🁖 🁗 🁘 🁙 🁚 🁛 🁜 🁝 🁞 🁟 🁠 🁡 🁢 🁣 🁤 🁥 🁦 🁧 🁨 🁩 🁪 🁫 🁬 🁭 🁮 🁯 🁰 🁱 🁲 🁳 🁴 🁵 🁶 🁷 🁸 🁹 🁺 🁻 🁼 🁽 🁾 🁿 🂀 🂁 🂂 🂃 🂄 🂅 🂆 🂇 🂈 🂉 🂊 🂋 🂌 🂍 🂎 🂏 🂐 🂑 🂒 🂓 🂠 🂡 🂢 🂣 🂤 🂥 🂦 🂧 🂨 🂩 🂪 🂫 🂬 🂭 🂮 🂱 🂲 🂳 🂴 🂵 🂶 🂷 🂸 🂹 🂺 🂻 🂼 🂽 🂾 🂿 🃁 🃂 🃃 🃄 🃅 🃆 🃇 🃈 🃉 🃊 🃋 🃌 🃍 🃎 🃑 🃒 🃓 🃔 🃕 🃖 🃗 🃘 🃙 🃚 🃛 🃜 🃝 🃞 🃟 🃠 🃡 🃢 🃣 🃤 🃥 🃦 🃧 🃨 🃩 🃪 🃫 🃬 🃭 🃮 🃯 🃰 🃱 🃲 🃳 🃴 🃵 🄍 🄎 🄏 🄯 🅬 🅭 🅮 🅯 🆭 🌢 🌣 🎔 🎕 🎘 🎜 🎝 🏱 🏲 🏶 📾 🕆 🕇 🕈 🕏 🕨 🕩 🕪 🕫 🕬 🕭 🕮 🕱 🕲 🕻 🕼 🕽 🕾 🕿 🖀 🖁 🖂 🖃 🖄 🖅 🖆 🖈 🖉 🖎 🖏 🖑 🖒 🖓 🖔 🖗 🖘 🖙 🖚 🖛 🖜 🖝 🖞 🖟 🖠 🖡 🖢 🖣 🖦 🖧 🖩 🖪 🖫 🖬 🖭 🖮 🖯 🖰 🖳 🖴 🖵 🖶 🖷 🖸 🖹 🖺 🖻 🖽 🖾 🖿 🗀 🗁 🗅 🗆 🗇 🗈 🗉 🗊 🗋 🗌 🗍 🗎 🗏 🗐 🗔 🗕 🗖 🗗 🗘 🗙 🗚 🗛 🗟 🗠 🗢 🗤 🗥 🗦 🗧 🗩 🗪 🗫 🗬 🗭 🗮 🗰 🗱 🗲 🗴 🗵 🗶 🗷 🗸 🗹 🛆 🛇 🛈 🛉 🛊 🛓 🛔 🛦 🛧 🛨 🛪 🛱 🛲 🝴 🝵 🝶 🝻 🝼 🝽 🝾 🝿 🟕 🟖 🟗 🟘 🟙 🢰 🢱 🨀 🨁 🨂 🨃 🨄 🨅 🨆 🨇 🨈 🨉 🨊 🨋 🨌 🨍 🨎 🨏 🨐 🨑 🨒 🨓 🨔 🨕 🨖 🨗 🨘 🨙 🨚 🨛 🨜 🨝 🨞 🨟 🨠 🨡 🨢 🨣 🨤 🨥 🨦 🨧 🨨 🨩 🨪 🨫 🨬 🨭 🨮 🨯 🨰 🨱 🨲 🨳 🨴 🨵 🨶 🨷 🨸 🨹 🨺 🨻 🨼 🨽 🨾 🨿 🩀 🩁 🩂 🩃 🩄 🩅 🩆 🩇 🩈 🩉 🩊 🩋 🩌 🩍 🩎 🩏 🩐 🩑 🩒 🩓 🩠 🩡 🩢 🩣 🩤 🩥 🩦 🩧 🩨 🩩 🩪 🩫 🩬 🩭 --- src/nvim/generators/gen_unicode_tables.lua | 264 ----------------------------- 1 file changed, 264 deletions(-) delete mode 100644 src/nvim/generators/gen_unicode_tables.lua (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_unicode_tables.lua b/src/nvim/generators/gen_unicode_tables.lua deleted file mode 100644 index 01eb34be88..0000000000 --- a/src/nvim/generators/gen_unicode_tables.lua +++ /dev/null @@ -1,264 +0,0 @@ --- Script creates the following tables in unicode_tables.generated.h: --- --- 1. doublewidth and ambiguous tables: sorted list of non-overlapping closed --- intervals. Codepoints in these intervals have double (W or F) or ambiguous --- (A) east asian width respectively. --- 2. combining table: same as the above, but characters inside are combining --- characters (i.e. have general categories equal to Mn, Mc or Me). --- 3. foldCase table used to convert characters to --- folded variants. In this table first two values are --- character ranges: like in previous tables they are sorted and must be --- non-overlapping. Third value means step inside the range: e.g. if it is --- 2 then interval applies only to first, third, fifth, … character in range. --- Fourth value is number that should be added to the codepoint to yield --- folded codepoint. --- 4. emoji_wide and emoji_all tables: sorted lists of non-overlapping closed --- intervals of Emoji characters. emoji_wide contains all the characters --- which don't have ambiguous or double width, and emoji_all has all Emojis. -if arg[1] == '--help' then - print('Usage:') - print(' gen_unicode_tables.lua unicode/ unicode_tables.generated.h') - os.exit(0) -end - -local basedir = arg[1] -local pathsep = package.config:sub(1, 1) -local get_path = function(fname) - return basedir .. pathsep .. fname -end - -local unicodedata_fname = get_path('UnicodeData.txt') -local eastasianwidth_fname = get_path('EastAsianWidth.txt') -local emoji_fname = get_path('emoji-data.txt') - -local utf_tables_fname = arg[2] - -local split_on_semicolons = function(s) - local ret = {} - local idx = 1 - while idx <= #s + 1 do - local item = s:match('^[^;]*', idx) - idx = idx + #item + 1 - if idx <= #s + 1 then - assert(s:sub(idx - 1, idx - 1) == ';') - end - item = item:gsub('^%s*', '') - item = item:gsub('%s*$', '') - table.insert(ret, item) - end - return ret -end - -local fp_lines_to_lists = function(fp, n, has_comments) - local ret = {} - local line - local i = 0 - while true do - i = i + 1 - line = fp:read('*l') - if not line then - break - end - 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('Line: ' .. line .. '\n') - return nil - end - table.insert(ret, l) - end - end - return ret -end - -local parse_data_to_props = function(ud_fp) - return fp_lines_to_lists(ud_fp, 15, false) -end - -local parse_width_props = function(eaw_fp) - return fp_lines_to_lists(eaw_fp, 2, true) -end - -local parse_emoji_props = function(emoji_fp) - return fp_lines_to_lists(emoji_fp, 2, true) -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) - else - return (' {0x%04x, 0x%04x},\n'):format(start, end_) - end -end - -local build_combining_table = function(ut_fp, dataprops) - ut_fp:write('static const struct interval combining[] = {\n') - local start = -1 - 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 - local n = tonumber(p[1], 16) - if start >= 0 and end_ + 1 == n then - -- Continue with the same range. - end_ = n - else - if start >= 0 then - -- Produce previous range. - ut_fp:write(make_range(start, end_)) - end - start = n - end_ = n - end - end - end - if start >= 0 then - ut_fp:write(make_range(start, end_)) - end - ut_fp:write('};\n') -end - -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 - local dataidx = 1 - local ret = {} - for _, p in ipairs(widthprops) do - if widths[p[2]:sub(1, 1)] then - local rng_start, rng_end = p[1]:find('%.%.') - local n, n_last - if rng_start then - -- It is a range. We don’t check for composing char then. - n = tonumber(p[1]:sub(1, rng_start - 1), 16) - n_last = tonumber(p[1]:sub(rng_end + 1), 16) - else - n = tonumber(p[1], 16) - n_last = n - end - local dn - while true do - dn = tonumber(dataprops[dataidx][1], 16) - if dn >= n then - break - end - dataidx = dataidx + 1 - end - if dn ~= n and n_last == n then - io.stderr:write('Cannot find character ' .. n .. ' in data table.\n') - end - -- 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 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_ }) - end - start = n - end - end_ = n_last - end - end - end - if start >= 0 then - ut_fp:write(make_range(start, end_)) - table.insert(ret, { start, end_ }) - end - ut_fp:write('};\n') - return ret -end - -local build_emoji_table = function(ut_fp, emojiprops, doublewidth, ambiwidth) - local emojiwidth = {} - local emoji = {} - for _, p in ipairs(emojiprops) do - if p[2]:match('Emoji%s+#') then - local rng_start, rng_end = p[1]:find('%.%.') - local n - local n_last - if rng_start then - n = tonumber(p[1]:sub(1, rng_start - 1), 16) - n_last = tonumber(p[1]:sub(rng_end + 1), 16) - else - n = tonumber(p[1], 16) - n_last = n - end - if #emoji > 0 and n - 1 == emoji[#emoji][2] then - emoji[#emoji][2] = n_last - else - table.insert(emoji, { n, n_last }) - end - - -- Characters below 1F000 may be considered single width traditionally, - -- making them double width causes problems. - if n >= 0x1f000 then - -- exclude characters that are in the ambiguous/doublewidth table - for _, ambi in ipairs(ambiwidth) do - if n >= ambi[1] and n <= ambi[2] then - n = ambi[2] + 1 - end - if n_last >= ambi[1] and n_last <= ambi[2] then - n_last = ambi[1] - 1 - end - end - for _, double in ipairs(doublewidth) do - if n >= double[1] and n <= double[2] then - n = double[2] + 1 - end - if n_last >= double[1] and n_last <= double[2] then - n_last = double[1] - 1 - end - end - - if n <= n_last then - if #emojiwidth > 0 and n - 1 == emojiwidth[#emojiwidth][2] then - emojiwidth[#emojiwidth][2] = n_last - else - table.insert(emojiwidth, { n, n_last }) - end - end - end - end - end - - ut_fp:write('static const struct interval emoji_all[] = {\n') - for _, p in ipairs(emoji) do - ut_fp:write(make_range(p[1], p[2])) - end - ut_fp:write('};\n') - - ut_fp:write('static const struct interval emoji_wide[] = {\n') - for _, p in ipairs(emojiwidth) do - ut_fp:write(make_range(p[1], p[2])) - end - ut_fp:write('};\n') -end - -local ud_fp = io.open(unicodedata_fname, 'r') -local dataprops = parse_data_to_props(ud_fp) -ud_fp:close() - -local ut_fp = io.open(utf_tables_fname, 'w') - -build_combining_table(ut_fp, dataprops) - -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 emoji_fp = io.open(emoji_fname, 'r') -local emojiprops = parse_emoji_props(emoji_fp) -emoji_fp:close() - -build_emoji_table(ut_fp, emojiprops, doublewidth, ambiwidth) - -ut_fp:close() -- cgit From 737f58e23230ea14f1648ac1fc7f442ea0f8563c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 20 Sep 2024 07:34:50 +0200 Subject: refactor(api)!: rename Dictionary => Dict In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change. --- src/nvim/generators/c_grammar.lua | 6 +----- src/nvim/generators/gen_api_dispatch.lua | 24 ++++++++++++------------ src/nvim/generators/gen_api_ui_events.lua | 6 +++--- src/nvim/generators/gen_declarations.lua | 2 +- src/nvim/generators/gen_options_enum.lua | 2 +- 5 files changed, 18 insertions(+), 22 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua index 4e7de7adb4..ed6e30ea10 100644 --- a/src/nvim/generators/c_grammar.lua +++ b/src/nvim/generators/c_grammar.lua @@ -35,11 +35,7 @@ local cdoc_comment = P('///') * opt(Ct(Cg(rep(space) * rep(not_nl), 'comment'))) local c_preproc = P('#') * rep(not_nl) local dllexport = P('DLLEXPORT') * rep1(ws) -local typed_container = ( - (P('ArrayOf(') + P('DictionaryOf(') + P('Dict(')) - * rep1(any - P(')')) - * P(')') -) +local typed_container = ((P('ArrayOf(') + P('DictOf(') + P('Dict(')) * rep1(any - P(')')) * P(')')) local c_id = (typed_container + (letter * rep(alpha))) local c_void = P('void') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 3567831c41..9e0aa407a1 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -216,15 +216,15 @@ for _, f in ipairs(functions) do end f_exported.parameters = {} for i, param in ipairs(f.parameters) do - if param[1] == 'DictionaryOf(LuaRef)' then - param = { 'Dictionary', param[2] } + if param[1] == 'DictOf(LuaRef)' then + param = { 'Dict', param[2] } elseif startswith(param[1], 'Dict(') then - param = { 'Dictionary', param[2] } + param = { 'Dict', param[2] } end f_exported.parameters[i] = param end if startswith(f.return_type, 'Dict(') then - f_exported.return_type = 'Dictionary' + f_exported.return_type = 'Dict' end exported_functions[#exported_functions + 1] = f_exported end @@ -406,7 +406,7 @@ local function real_type(type) if rv:match('Array') then rv = 'Array' else - rv = 'Dictionary' + rv = 'Dict' end end return rv @@ -466,7 +466,7 @@ for i = 1, #functions do output:write('\n ' .. converted .. ' = args.items[' .. (j - 1) .. '];\n') elseif rt:match('^KeyDict_') then converted = '&' .. converted - output:write('\n if (args.items[' .. (j - 1) .. '].type == kObjectTypeDictionary) {') --luacheck: ignore 631 + output:write('\n if (args.items[' .. (j - 1) .. '].type == kObjectTypeDict) {') --luacheck: ignore 631 output:write('\n memset(' .. converted .. ', 0, sizeof(*' .. converted .. '));') -- TODO: neeeee output:write( '\n if (!api_dict_to_keydict(' @@ -475,7 +475,7 @@ for i = 1, #functions do .. rt .. '_get_field, args.items[' .. (j - 1) - .. '].data.dictionary, error)) {' + .. '].data.dict, error)) {' ) output:write('\n goto cleanup;') output:write('\n }') @@ -554,7 +554,7 @@ for i = 1, #functions do ) end -- accept empty lua tables as empty dictionaries - if rt:match('^Dictionary') then + if rt:match('^Dict') then output:write( '\n } else if (args.items[' .. (j - 1) @@ -562,7 +562,7 @@ for i = 1, #functions do .. (j - 1) .. '].data.array.size == 0) {' ) --luacheck: ignore 631 - output:write('\n ' .. converted .. ' = (Dictionary)ARRAY_DICT_INIT;') + output:write('\n ' .. converted .. ' = (Dict)ARRAY_DICT_INIT;') end output:write('\n } else {') output:write( @@ -643,7 +643,7 @@ for i = 1, #functions do if string.match(ret_type, '^KeyDict_') then local table = string.sub(ret_type, 9) .. '_table' output:write( - '\n ret = DICTIONARY_OBJ(api_keydict_to_dict(&rv, ' + '\n ret = DICT_OBJ(api_keydict_to_dict(&rv, ' .. table .. ', ARRAY_SIZE(' .. table @@ -779,12 +779,12 @@ local function process_function(fn) local param = fn.parameters[j] local cparam = string.format('arg%u', j) local param_type = real_type(param[1]) - local extra = param_type == 'Dictionary' and 'false, ' or '' + local extra = param_type == 'Dict' and 'false, ' or '' local arg_free_code = '' if param[1] == 'Object' then extra = 'true, ' arg_free_code = 'api_luarefs_free_object(' .. cparam .. ');' - elseif param[1] == 'DictionaryOf(LuaRef)' then + elseif param[1] == 'DictOf(LuaRef)' then extra = 'true, ' arg_free_code = 'api_luarefs_free_dict(' .. cparam .. ');' elseif param[1] == 'LuaRef' then diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index c5b37672bf..7f90039090 100644 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -54,7 +54,7 @@ local function call_ui_event_method(output, ev) local kind = ev.parameters[j][1] if kind ~= 'Object' then if kind == 'HlAttrs' then - kind = 'Dictionary' + kind = 'Dict' end output:write('\n || args.items[' .. (j - 1) .. '].type != kObjectType' .. kind .. '') end @@ -74,7 +74,7 @@ local function call_ui_event_method(output, ev) output:write( 'ui_client_dict2hlattrs(args.items[' .. (j - 1) - .. '].data.dictionary, ' + .. '].data.dict, ' .. (hlattrs_args_count == 0 and 'true' or 'false') .. ');\n' ) @@ -206,7 +206,7 @@ for _, ev in ipairs(events) do end for _, p in ipairs(ev_exported.parameters) do if p[1] == 'HlAttrs' then - p[1] = 'Dictionary' + p[1] = 'Dict' end end if not ev.noexport then diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index f4d1d19481..2ec0e9ab68 100644 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -70,7 +70,7 @@ local raw_word = concat(w, any_amount(aw)) local right_word = concat(raw_word, neg_look_ahead(aw)) local word = branch( concat( - branch(lit('ArrayOf('), lit('DictionaryOf('), lit('Dict(')), -- typed container macro + branch(lit('ArrayOf('), lit('DictOf('), lit('Dict(')), -- typed container macro one_or_more(any_character - lit(')')), lit(')') ), diff --git a/src/nvim/generators/gen_options_enum.lua b/src/nvim/generators/gen_options_enum.lua index 9a3953fcbc..d1419137d3 100644 --- a/src/nvim/generators/gen_options_enum.lua +++ b/src/nvim/generators/gen_options_enum.lua @@ -80,7 +80,7 @@ enum_w('') --- @type { [string]: string } local option_index = {} --- Generate option index enum and populate the `option_index` dictionary. +-- Generate option index enum and populate the `option_index` dict. enum_w('typedef enum {') enum_w(' kOptInvalid = -1,') -- cgit From 17027d64726864c7bbdba5bee004eb581ac4b54a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Sep 2024 12:15:06 +0200 Subject: refactor(api): rename Dictionary => Dict In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not a breaking change. --- src/nvim/generators/gen_api_ui_events.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index 7f90039090..3e8ae19c9a 100644 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -205,8 +205,9 @@ for _, ev in ipairs(events) do ev_exported[attr] = ev[attr] end for _, p in ipairs(ev_exported.parameters) do - if p[1] == 'HlAttrs' then - p[1] = 'Dict' + if p[1] == 'HlAttrs' or p[1] == 'Dict' then + -- TODO(justinmk): for back-compat, but do clients actually look at this? + p[1] = 'Dictionary' end end if not ev.noexport then -- cgit