From f31db30975479cb6b57247f124a65f4362f80bfe Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 30 Jun 2022 13:26:31 +0600 Subject: feat(lua): vim.ui_attach to get ui events from lua Co-authored-by: Famiu Haque --- src/nvim/generators/gen_api_ui_events.lua | 2 ++ 1 file changed, 2 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 f9e888c20d..ea66be7ee8 100755 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -75,6 +75,8 @@ local function call_ui_event_method(output, ev) hlattrs_args_count = hlattrs_args_count + 1 elseif kind == 'Object' then output:write('args.items['..(j-1)..'];\n') + elseif kind == 'Window' then + output:write('(Window)args.items['..(j-1)..'].data.integer;\n') else output:write('args.items['..(j-1)..'].data.'..string.lower(kind)..';\n') end -- cgit From c5322e752e9e568de907f7a1ef733bbfe342140c Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- 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 0454c54faf..24b4739fc7 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -115,7 +115,7 @@ local value_dumpers = { } local get_value = function(v) - return '(char_u *) ' .. value_dumpers[type(v)](v) + return '(char *) ' .. value_dumpers[type(v)](v) end local get_defaults = function(d,n) -- cgit From 6d557e324fd4223fff3279a0112f40431c540163 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 18 Sep 2022 03:17:15 +0200 Subject: vim-patch:8.1.0941: macros for MS-Windows are inconsistent (#20215) Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes vim/vim#3932) https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9 --- src/nvim/generators/gen_declarations.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index c7d5a1a191..bf1adaeee3 100755 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -218,7 +218,7 @@ local footer = [[ local non_static = header .. [[ #ifndef DLLEXPORT -# ifdef WIN32 +# ifdef MSWIN # define DLLEXPORT __declspec(dllexport) # else # define DLLEXPORT -- cgit From 6679687bb3909f853ae97dfa01ae08ea2baf7f97 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 26 Sep 2022 15:17:10 +0200 Subject: refactor(redraw): no type argument in update_screen() This was used in the past with assumption that curwin/curbuf is "special" but this has not been true since basically forever at this point. Reduce NOT_VALID/CLEAR panic in options.lua . These should not be set if an effect of the option is causing something which by itself invokes redraw_later(). --- src/nvim/generators/gen_options.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 24b4739fc7..6dba6552b3 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -34,7 +34,6 @@ local redraw_flags={ current_window_only='P_RWINONLY', current_buffer='P_RBUF', all_windows='P_RALL', - everything='P_RCLR', curswant='P_CURSWANT', ui_option='P_UI_OPTION', } -- cgit From 09325845b9b6c9c3a61feef189c5b80094f51a5b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 7 Oct 2022 06:44:29 +0800 Subject: vim-patch:9.0.0666: spacing-combining characters handled as composing (#20501) Problem: Spacing-combining characters handled as composing, causing text to take more space than expected. Solution: Handle characters marked with "Mc" not as composing. (closes vim/vim#11282 https://github.com/vim/vim/commit/7beaf6a720ddc7e2989c8831872bfb98ec78a65d --- src/nvim/generators/gen_unicode_tables.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_unicode_tables.lua b/src/nvim/generators/gen_unicode_tables.lua index 36553f4649..9ad99c8029 100644 --- a/src/nvim/generators/gen_unicode_tables.lua +++ b/src/nvim/generators/gen_unicode_tables.lua @@ -153,7 +153,8 @@ local build_combining_table = function(ut_fp, dataprops) local start = -1 local end_ = -1 for _, p in ipairs(dataprops) do - if (({Mn=true, Mc=true, Me=true})[p[3]]) then + -- 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. -- cgit From 288208257c8d6b3c8dcce7ee6c7b6c7bb7bafb27 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 8 Oct 2022 15:48:07 +0100 Subject: feat(cscope)!: remove --- src/nvim/generators/gen_declarations.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index bf1adaeee3..4097ff7dc5 100755 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -182,8 +182,7 @@ Additionally uses the following environment variables: If set to 1 then all generated declarations receive a comment with file name and line number after the declaration. This may be useful for debugging gen_declarations script, but not much beyond that with - configured development environment (i.e. with ctags/cscope/finding - definitions with clang/etc). + configured development environment (i.e. with with clang/etc). WARNING: setting this to 1 will cause extensive rebuilds: declarations generator script will not regenerate non-static.h file if its -- cgit From a53998ae78902309c225b323e0b8d9f1f75fe147 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Sat, 22 Oct 2022 13:54:29 +0600 Subject: fix: setting tabline option not redrawing tabline With #20374 tabline option is marked with 'statuslines' redraw flag. But 'statuslines' doesn't redraw tabline. As a result, tabline doesn't get redrawn when tabline option is set and statuslines get unnecessarily redrawn. This patch fixes the issue by adding a new redraw flag P_RTABL to redraw tabline. --- src/nvim/generators/gen_options.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 6dba6552b3..4e4dd83367 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -30,6 +30,7 @@ local type_flags={ local redraw_flags={ statuslines='P_RSTAT', + tabline = 'P_RTABL', current_window='P_RWIN', current_window_only='P_RWINONLY', current_buffer='P_RBUF', -- cgit From 42e44d6d334bda8b97afe9e34a819ab293e5e10a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 7 Nov 2022 10:26:54 +0800 Subject: vim-patch:8.2.3751: cannot assign a lambda to an option that takes a function Problem: Cannot assign a lambda to an option that takes a function. Solution: Automatically convert the lambda to a string. (Yegappan Lakshmanan, closes vim/vim#9286) https://github.com/vim/vim/commit/6409553b6e3b4de4e1d72b8ee5445595214581ff Co-authored-by: Yegappan Lakshmanan --- src/nvim/generators/gen_options.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 4e4dd83367..af21d44eaf 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -29,14 +29,14 @@ local type_flags={ } local redraw_flags={ + ui_option='P_UI_OPTION', + tabline='P_RTABL', statuslines='P_RSTAT', - tabline = 'P_RTABL', current_window='P_RWIN', current_window_only='P_RWINONLY', current_buffer='P_RBUF', all_windows='P_RALL', curswant='P_CURSWANT', - ui_option='P_UI_OPTION', } local list_flags={ @@ -78,6 +78,7 @@ local get_flags = function(o) {'deny_in_modelines', 'P_NO_ML'}, {'deny_duplicates', 'P_NODUP'}, {'modelineexpr', 'P_MLE'}, + {'func'} }) do local key_name = flag_desc[1] local def_name = flag_desc[2] or ('P_' .. key_name:upper()) -- cgit From f8c671827710c6e9cca3bfd60c32098b2be8239a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 14 Nov 2022 18:04:36 +0000 Subject: feat(lua-api): avoid unnecessary allocations (#19877) Lua makes (or reuses) an internal copy of strings, so we can safely push buf pointers onto the stack. --- src/nvim/generators/c_grammar.lua | 1 + src/nvim/generators/gen_api_dispatch.lua | 34 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua index d872ffd6a9..3ea5904338 100644 --- a/src/nvim/generators/c_grammar.lua +++ b/src/nvim/generators/c_grammar.lua @@ -27,6 +27,7 @@ local c_void = P('void') local c_param_type = ( ((P('Error') * fill * P('*') * fill) * Cc('error')) + ((P('Arena') * fill * P('*') * fill) * Cc('arena')) + + ((P('lua_State') * fill * P('*') * fill) * Cc('lstate')) + C((P('const ') ^ -1) * (c_id) * (ws ^ 1) * P('*')) + (C(c_id) * (ws ^ 1)) ) diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 67b8f5f0f5..6894b7a6df 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -78,6 +78,10 @@ for i = 6, #arg do fn.arena_return = true fn.parameters[#fn.parameters] = nil end + if #fn.parameters ~= 0 and fn.parameters[#fn.parameters][1] == 'lstate' then + fn.has_lua_imp = true + fn.parameters[#fn.parameters] = nil + end end end input:close() @@ -329,6 +333,14 @@ for i = 1, #functions do output:write(', arena') end + if fn.has_lua_imp then + if #args > 0 then + output:write(', NULL') + else + output:write('NULL') + end + end + if fn.can_fail then -- if the function can fail, also pass a pointer to the local error object if #args > 0 then @@ -497,6 +509,10 @@ local function process_function(fn) ]]) end + if fn.has_lua_imp then + cparams = cparams .. 'lstate, ' + end + if fn.can_fail then cparams = cparams .. '&err' else @@ -539,13 +555,27 @@ local function process_function(fn) end write_shifted_output(output, string.format([[ const %s ret = %s(%s); + ]], fn.return_type, fn.name, cparams)) + + if fn.has_lua_imp then + -- only push onto the Lua stack if we haven't already + write_shifted_output(output, string.format([[ + if (lua_gettop(lstate) == 0) { + nlua_push_%s(lstate, ret, true); + } + ]], return_type)) + else + write_shifted_output(output, string.format([[ nlua_push_%s(lstate, ret, true); + ]], return_type)) + end + + write_shifted_output(output, string.format([[ %s %s %s return 1; - ]], fn.return_type, fn.name, cparams, return_type, - free_retval, free_at_exit_code, err_throw_code)) + ]], free_retval, free_at_exit_code, err_throw_code)) else write_shifted_output(output, string.format([[ %s(%s); -- cgit From 66360675cf4d091b7460e4a8e1435c13216c1929 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 11 Sep 2022 17:12:44 +0200 Subject: build: allow IWYU to fix includes for all .c files Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers. --- src/nvim/generators/gen_api_dispatch.lua | 29 +++++++++++++++++++++++++ src/nvim/generators/gen_eval.lua | 25 +++++++++++++++++++++ src/nvim/generators/gen_ex_cmds.lua | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 6894b7a6df..d4fe455f82 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -189,6 +189,35 @@ funcs_metadata_output:close() -- start building the dispatch wrapper output local output = io.open(dispatch_outputf, 'wb') + +-- =========================================================================== +-- NEW API FILES MUST GO HERE. +-- +-- When creating a new API file, you must include it here, +-- so that the dispatcher can find the C functions that you are creating! +-- =========================================================================== +output:write([[ +#include "nvim/log.h" +#include "nvim/map.h" +#include "nvim/msgpack_rpc/helpers.h" +#include "nvim/vim.h" + +#include "nvim/api/autocmd.h" +#include "nvim/api/buffer.h" +#include "nvim/api/command.h" +#include "nvim/api/deprecated.h" +#include "nvim/api/extmark.h" +#include "nvim/api/options.h" +#include "nvim/api/tabpage.h" +#include "nvim/api/ui.h" +#include "nvim/api/vim.h" +#include "nvim/api/vimscript.h" +#include "nvim/api/win_config.h" +#include "nvim/api/window.h" +#include "nvim/ui_client.h" + +]]) + local function real_type(type) local rv = type local rmatch = string.match(type, "Dict%(([_%w]+)%)") diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua index 8e6d1f2634..9159a3a200 100644 --- a/src/nvim/generators/gen_eval.lua +++ b/src/nvim/generators/gen_eval.lua @@ -27,6 +27,31 @@ local hashy = require'generators.hashy' local hashpipe = io.open(funcsfname, 'wb') +hashpipe:write([[ +#include "nvim/arglist.h" +#include "nvim/cmdexpand.h" +#include "nvim/cmdhist.h" +#include "nvim/digraph.h" +#include "nvim/eval/funcs.h" +#include "nvim/eval/typval.h" +#include "nvim/eval/vars.h" +#include "nvim/ex_docmd.h" +#include "nvim/ex_getln.h" +#include "nvim/fold.h" +#include "nvim/getchar.h" +#include "nvim/insexpand.h" +#include "nvim/mapping.h" +#include "nvim/match.h" +#include "nvim/mbyte.h" +#include "nvim/menu.h" +#include "nvim/move.h" +#include "nvim/quickfix.h" +#include "nvim/search.h" +#include "nvim/sign.h" +#include "nvim/testing.h" + +]]) + local funcs = require('eval').funcs for _, func in pairs(funcs) do if func.float_func then diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua index 255c415a4d..ac60b9f8e9 100644 --- a/src/nvim/generators/gen_ex_cmds.lua +++ b/src/nvim/generators/gen_ex_cmds.lua @@ -49,6 +49,43 @@ enumfile:write([[ typedef enum CMD_index { ]]) defsfile:write(string.format([[ +#include "nvim/arglist.h" +#include "nvim/autocmd.h" +#include "nvim/buffer.h" +#include "nvim/cmdhist.h" +#include "nvim/debugger.h" +#include "nvim/diff.h" +#include "nvim/digraph.h" +#include "nvim/eval.h" +#include "nvim/eval/userfunc.h" +#include "nvim/eval/vars.h" +#include "nvim/ex_cmds.h" +#include "nvim/ex_cmds2.h" +#include "nvim/ex_docmd.h" +#include "nvim/ex_eval.h" +#include "nvim/ex_session.h" +#include "nvim/hardcopy.h" +#include "nvim/help.h" +#include "nvim/locale.h" +#include "nvim/lua/executor.h" +#include "nvim/mapping.h" +#include "nvim/mark.h" +#include "nvim/match.h" +#include "nvim/menu.h" +#include "nvim/message.h" +#include "nvim/ops.h" +#include "nvim/option.h" +#include "nvim/profile.h" +#include "nvim/quickfix.h" +#include "nvim/runtime.h" +#include "nvim/sign.h" +#include "nvim/spell.h" +#include "nvim/spellfile.h" +#include "nvim/syntax.h" +#include "nvim/undo.h" +#include "nvim/usercmd.h" +#include "nvim/version.h" + static const int command_count = %u; static CommandDefinition cmdnames[%u] = { ]], #defs, #defs)) -- cgit From 0b79137c59fbe44bded76f123602e552dc6f7b03 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 29 Nov 2022 16:47:29 +0800 Subject: vim-patch:8.1.2001: some source files are too big (#21231) Problem: Some source files are too big. Solution: Move buffer and window related functions to evalbuffer.c and evalwindow.c. (Yegappan Lakshmanan, closes vim/vim#4898) https://github.com/vim/vim/commit/261f346f8154c0ec7094a4a211c653c74e9f7c2e --- src/nvim/generators/gen_eval.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua index 9159a3a200..a50e058e00 100644 --- a/src/nvim/generators/gen_eval.lua +++ b/src/nvim/generators/gen_eval.lua @@ -32,9 +32,11 @@ hashpipe:write([[ #include "nvim/cmdexpand.h" #include "nvim/cmdhist.h" #include "nvim/digraph.h" +#include "nvim/eval/buffer.h" #include "nvim/eval/funcs.h" #include "nvim/eval/typval.h" #include "nvim/eval/vars.h" +#include "nvim/eval/window.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/fold.h" -- cgit From e0c7b8955d0193ebbc7df703179ecb035f73fec7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 30 Nov 2022 10:12:09 +0800 Subject: refactor: move ex_retab() to indent.c --- src/nvim/generators/gen_ex_cmds.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua index ac60b9f8e9..3a022d45c8 100644 --- a/src/nvim/generators/gen_ex_cmds.lua +++ b/src/nvim/generators/gen_ex_cmds.lua @@ -66,6 +66,7 @@ defsfile:write(string.format([[ #include "nvim/ex_session.h" #include "nvim/hardcopy.h" #include "nvim/help.h" +#include "nvim/indent.h" #include "nvim/locale.h" #include "nvim/lua/executor.h" #include "nvim/mapping.h" -- cgit From 24488169564c39a506c235bf6a33b8e23a8cb528 Mon Sep 17 00:00:00 2001 From: hlpr98 Date: Mon, 27 May 2019 22:04:24 +0530 Subject: feat(tui): run TUI as external process --- src/nvim/generators/gen_api_dispatch.lua | 40 ++++++++++++++++---- src/nvim/generators/gen_api_ui_events.lua | 63 ++----------------------------- 2 files changed, 35 insertions(+), 68 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index d4fe455f82..240b99ca29 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -60,6 +60,12 @@ for i = 6, #arg do if public and not fn.noexport then functions[#functions + 1] = tmp[j] function_names[fn.name] = true + if #fn.parameters >= 2 and fn.parameters[2][1] == 'Array' and fn.parameters[2][2] == 'uidata' then + -- function recieves the "args" as a parameter + fn.receives_array_args = true + -- remove the args parameter + table.remove(fn.parameters, 2) + end if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then -- this function should receive the channel id fn.receives_channel_id = true @@ -159,7 +165,7 @@ local exported_attributes = {'name', 'return_type', 'method', 'since', 'deprecated_since'} local exported_functions = {} for _,f in ipairs(functions) do - if not (startswith(f.name, "nvim__") or f.name == "nvim_error_event") then + if not (startswith(f.name, "nvim__") or f.name == "nvim_error_event" or f.name == "redraw") then local f_exported = {} for _,attr in ipairs(exported_attributes) do f_exported[attr] = f[attr] @@ -264,11 +270,13 @@ for i = 1, #functions do output:write('\n '..rt..' '..converted..';') end output:write('\n') - output:write('\n if (args.size != '..#fn.parameters..') {') - output:write('\n api_set_error(error, kErrorTypeException, \ - "Wrong number of arguments: expecting '..#fn.parameters..' but got %zu", args.size);') - output:write('\n goto cleanup;') - output:write('\n }\n') + if not fn.receives_array_args then + output:write('\n if (args.size != '..#fn.parameters..') {') + output:write('\n api_set_error(error, kErrorTypeException, \ + "Wrong number of arguments: expecting '..#fn.parameters..' but got %zu", args.size);') + output:write('\n goto cleanup;') + output:write('\n }\n') + end -- Validation/conversion for each argument for j = 1, #fn.parameters do @@ -350,12 +358,28 @@ for i = 1, #functions do if fn.receives_channel_id then -- if the function receives the channel id, pass it as first argument if #args > 0 or fn.can_fail then - output:write('channel_id, '..call_args) + output:write('channel_id, ') + if fn.receives_array_args then + -- if the function recieves the array args, pass it the second argument + output:write('args, ') + end + output:write(call_args) else output:write('channel_id') + if fn.receives_array_args then + output:write(', args') + end end else - output:write(call_args) + if fn.receives_array_args then + if #args > 0 or fn.call_fail then + output:write('args, '..call_args) + else + output:write('args') + end + else + output:write(call_args) + end end if fn.arena_return then diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index ea66be7ee8..c9a2e3ff66 100755 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -3,14 +3,13 @@ local mpack = require('mpack') local nvimdir = arg[1] package.path = nvimdir .. '/?.lua;' .. package.path -assert(#arg == 8) +assert(#arg == 7) local input = io.open(arg[2], 'rb') local proto_output = io.open(arg[3], 'wb') local call_output = io.open(arg[4], 'wb') local remote_output = io.open(arg[5], 'wb') -local bridge_output = io.open(arg[6], 'wb') -local metadata_output = io.open(arg[7], 'wb') -local client_output = io.open(arg[8], 'wb') +local metadata_output = io.open(arg[6], 'wb') +local client_output = io.open(arg[7], 'wb') local c_grammar = require('generators.c_grammar') local events = c_grammar.grammar:match(input:read('*all')) @@ -119,62 +118,6 @@ for i = 1, #events do remote_output:write(' push_call(ui, "'..ev.name..'", args);\n') remote_output:write('}\n\n') end - - if not ev.bridge_impl and not ev.noexport then - local send, argv, recv, recv_argv, recv_cleanup = '', '', '', '', '' - local argc = 1 - for j = 1, #ev.parameters do - local param = ev.parameters[j] - local copy = 'copy_'..param[2] - if param[1] == 'String' then - send = send..' String copy_'..param[2]..' = copy_string('..param[2]..', NULL);\n' - argv = argv..', '..copy..'.data, INT2PTR('..copy..'.size)' - recv = (recv..' String '..param[2].. - ' = (String){.data = argv['..argc..'],'.. - '.size = (size_t)argv['..(argc+1)..']};\n') - recv_argv = recv_argv..', '..param[2] - recv_cleanup = recv_cleanup..' api_free_string('..param[2]..');\n' - argc = argc+2 - elseif param[1] == 'Array' then - send = send..' Array '..copy..' = copy_array('..param[2]..', NULL);\n' - argv = argv..', '..copy..'.items, INT2PTR('..copy..'.size)' - recv = (recv..' Array '..param[2].. - ' = (Array){.items = argv['..argc..'],'.. - '.size = (size_t)argv['..(argc+1)..']};\n') - recv_argv = recv_argv..', '..param[2] - recv_cleanup = recv_cleanup..' api_free_array('..param[2]..');\n' - argc = argc+2 - elseif param[1] == 'Object' then - send = send..' Object *'..copy..' = xmalloc(sizeof(Object));\n' - send = send..' *'..copy..' = copy_object('..param[2]..', NULL);\n' - argv = argv..', '..copy - recv = recv..' Object '..param[2]..' = *(Object *)argv['..argc..'];\n' - recv_argv = recv_argv..', '..param[2] - recv_cleanup = (recv_cleanup..' api_free_object('..param[2]..');\n'.. - ' xfree(argv['..argc..']);\n') - argc = argc+1 - elseif param[1] == 'Integer' or param[1] == 'Boolean' then - argv = argv..', INT2PTR('..param[2]..')' - recv_argv = recv_argv..', PTR2INT(argv['..argc..'])' - argc = argc+1 - else - assert(false) - end - end - bridge_output:write('static void ui_bridge_'..ev.name.. - '_event(void **argv)\n{\n') - bridge_output:write(' UI *ui = UI(argv[0]);\n') - bridge_output:write(recv) - bridge_output:write(' ui->'..ev.name..'(ui'..recv_argv..');\n') - bridge_output:write(recv_cleanup) - bridge_output:write('}\n\n') - - bridge_output:write('static void ui_bridge_'..ev.name) - write_signature(bridge_output, ev, 'UI *ui') - bridge_output:write('\n{\n') - bridge_output:write(send) - bridge_output:write(' UI_BRIDGE_CALL(ui, '..ev.name..', '..argc..', ui'..argv..');\n}\n\n') - end end if not (ev.remote_only and ev.remote_impl) then -- cgit From 43e8ec92de9e0850e7d202cb7ff9051bc408447e Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 2 May 2022 21:10:01 +0200 Subject: fix(tui): more work in the TUI --- src/nvim/generators/gen_api_dispatch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 240b99ca29..55ab9fdf0e 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -363,7 +363,7 @@ for i = 1, #functions do -- if the function recieves the array args, pass it the second argument output:write('args, ') end - output:write(call_args) + output:write(call_args) else output:write('channel_id') if fn.receives_array_args then -- cgit From 5841a97500bffa5a2b9eed2eb41025f5587790ba Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 3 Jan 2023 10:07:43 +0000 Subject: feat!: remove hardcopy Co-authored-by: Justin M. Keyes --- src/nvim/generators/gen_ex_cmds.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua index 3a022d45c8..0c1051b04e 100644 --- a/src/nvim/generators/gen_ex_cmds.lua +++ b/src/nvim/generators/gen_ex_cmds.lua @@ -64,7 +64,6 @@ defsfile:write(string.format([[ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_session.h" -#include "nvim/hardcopy.h" #include "nvim/help.h" #include "nvim/indent.h" #include "nvim/locale.h" -- cgit From 936e191fef9865600af211c29ea4959ffbce81dd Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 4 Jan 2023 00:38:48 +0100 Subject: docs: fix typos (#21427) Co-authored-by: Gustavo Sampaio Co-authored-by: C.D. MacEachern Co-authored-by: Sean Dewar Co-authored-by: Tomas Nemec --- src/nvim/generators/gen_api_dispatch.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 55ab9fdf0e..96c9b21b8f 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -61,7 +61,7 @@ for i = 6, #arg do functions[#functions + 1] = tmp[j] function_names[fn.name] = true if #fn.parameters >= 2 and fn.parameters[2][1] == 'Array' and fn.parameters[2][2] == 'uidata' then - -- function recieves the "args" as a parameter + -- function receives the "args" as a parameter fn.receives_array_args = true -- remove the args parameter table.remove(fn.parameters, 2) @@ -360,7 +360,7 @@ for i = 1, #functions do if #args > 0 or fn.can_fail then output:write('channel_id, ') if fn.receives_array_args then - -- if the function recieves the array args, pass it the second argument + -- if the function receives the array args, pass it the second argument output:write('args, ') end output:write(call_args) -- cgit From 47ba78f89a1f0bba8168b4408bc55a3024d5ab97 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 30 Dec 2022 22:17:01 +0100 Subject: refactor(ui): devirtualize the ui layer - The defined interface for the UI is only the RPC protocol. The original UI interface as an array of function pointers fill no function. - On the server, all the UI:s are all RPC channels. - ui.c is only used on the server. - The compositor is a preprocessing step for single-grid UI:s - on the client, ui_client and tui talk directly to each other - we still do module separation, as ui_client.c could form the basis of a libnvim client module later. Items for later PR:s - vim.ui_attach is still an unhappy child, reconsider based on plugin experience. - the flags in ui_events.in.h are still a mess. Can be simplified now. - UX for remote attachment needs more work. - startup for client can be simplified further (think of the millisecs we can save) --- src/nvim/generators/c_grammar.lua | 2 +- src/nvim/generators/gen_api_ui_events.lua | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src/nvim/generators') diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua index 3ea5904338..3e89b60b4a 100644 --- a/src/nvim/generators/c_grammar.lua +++ b/src/nvim/generators/c_grammar.lua @@ -49,9 +49,9 @@ local c_proto = Ct( (fill * Cg((P('FUNC_API_LUA_ONLY') * Cc(true)), 'lua_only') ^ -1) * (fill * Cg((P('FUNC_API_CHECK_TEXTLOCK') * Cc(true)), 'check_textlock') ^ -1) * (fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1) * - (fill * Cg((P('FUNC_API_BRIDGE_IMPL') * Cc(true)), 'bridge_impl') ^ -1) * (fill * Cg((P('FUNC_API_COMPOSITOR_IMPL') * Cc(true)), 'compositor_impl') ^ -1) * (fill * Cg((P('FUNC_API_CLIENT_IMPL') * Cc(true)), 'client_impl') ^ -1) * + (fill * Cg((P('FUNC_API_CLIENT_IGNORE') * Cc(true)), 'client_ignore') ^ -1) * fill * P(';') ) diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index c9a2e3ff66..827097f69d 100755 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -3,13 +3,12 @@ local mpack = require('mpack') local nvimdir = arg[1] package.path = nvimdir .. '/?.lua;' .. package.path -assert(#arg == 7) +assert(#arg == 6) local input = io.open(arg[2], 'rb') -local proto_output = io.open(arg[3], 'wb') -local call_output = io.open(arg[4], 'wb') -local remote_output = io.open(arg[5], 'wb') -local metadata_output = io.open(arg[6], 'wb') -local client_output = io.open(arg[7], 'wb') +local call_output = io.open(arg[3], 'wb') +local remote_output = io.open(arg[4], 'wb') +local metadata_output = io.open(arg[5], 'wb') +local client_output = io.open(arg[6], 'wb') local c_grammar = require('generators.c_grammar') local events = c_grammar.grammar:match(input:read('*all')) @@ -81,12 +80,9 @@ local function call_ui_event_method(output, ev) end end - output:write(' ui_call_'..ev.name..'(') + output:write(' tui_'..ev.name..'(tui') for j = 1, #ev.parameters do - output:write('arg_'..j) - if j ~= #ev.parameters then - output:write(', ') - end + output:write(', arg_'..j) end output:write(');\n') @@ -104,12 +100,9 @@ for i = 1, #events do ev.since = tonumber(ev.since) if not ev.remote_only then - proto_output:write(' void (*'..ev.name..')') - write_signature(proto_output, ev, 'UI *ui') - proto_output:write(';\n') if not ev.remote_impl and not ev.noexport then - remote_output:write('static void remote_ui_'..ev.name) + remote_output:write('void remote_ui_'..ev.name) write_signature(remote_output, ev, 'UI *ui') remote_output:write('\n{\n') remote_output:write(' UIData *data = ui->data;\n') @@ -130,6 +123,9 @@ for i = 1, #events do call_output:write(' UI_LOG('..ev.name..');\n') call_output:write(' ui_call_event("'..ev.name..'", args);\n') elseif ev.compositor_impl then + call_output:write(' ui_comp_'..ev.name) + write_signature(call_output, ev, '', true) + call_output:write(";\n") call_output:write(' UI_CALL') write_signature(call_output, ev, '!ui->composed, '..ev.name..', ui', true) call_output:write(";\n") @@ -151,14 +147,14 @@ for i = 1, #events do call_output:write("}\n\n") end - if (not ev.remote_only) and (not ev.noexport) and (not ev.client_impl) then + if (not ev.remote_only) and (not ev.noexport) and (not ev.client_impl) and (not ev.client_ignore) then call_ui_event_method(client_output, ev) end end local client_events = {} for _,ev in ipairs(events) do - if (not ev.noexport) and ((not ev.remote_only) or ev.client_impl) then + if (not ev.noexport) and ((not ev.remote_only) or ev.client_impl) and (not ev.client_ignore) then client_events[ev.name] = ev end end @@ -176,7 +172,6 @@ end client_output:write('\n};\n\n') client_output:write(hashfun) -proto_output:close() call_output:close() remote_output:close() client_output:close() -- cgit