-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[RFC] main: make --embed wait for first request so embedding UI can display startup messages #8754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Also, later on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the lint warning
src/nvim/main.c
Outdated
@@ -819,6 +829,14 @@ static void command_line_scan(mparm_T *parmp) | |||
mch_exit(0); | |||
} else if (STRICMP(argv[0] + argv_idx, "headless") == 0) { | |||
headless_mode = true; | |||
} else if (STRICMP(argv[0] + argv_idx, "embed-ui") == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this option (later) be added to nvim --help
and the internal help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be added now.
Yes, I will add some docs and test also :) |
Messages sometimes get truncated, so this needs some more work. |
After some discussion with @justinmk I think we could use the following rule to avoid adding more an option: with |
8e1a1ef
to
a4653be
Compare
4a75398
to
89fb426
Compare
Update: now handles messages more consistently with TUI (never show more than one "press RETURN" prompt, unless the screen is really full or something). Note: unlike early TUI early messages can here be affected by colors loaded by vimrc. Which means if one message was displayed before |
test/functional/helpers.lua
Outdated
@@ -362,6 +362,7 @@ local function clear(...) | |||
table.insert(args, arg) | |||
end | |||
set_session(spawn(args, nil, env)) | |||
session:request('nvim_eval', "0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a comment:
-- Dummy request so that --embed starts the UI.
@@ -128,6 +128,7 @@ for i,f in ipairs(shallowcopy(functions)) do | |||
end | |||
newf.impl_name = f.name | |||
newf.remote_only = true | |||
newf.async = f.async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this affect behavior somewhere or only api_info metadata ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have forgotten to remove this line, shallowcopy(f)
already handles this...
Updated with a note in |
Added tests. |
src/nvim/msgpack_rpc/channel.c
Outdated
@@ -40,6 +40,8 @@ | |||
static PMap(cstr_t) *event_strings = NULL; | |||
static msgpack_sbuffer out_buffer; | |||
|
|||
static bool seen_stdio_request = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got_stdio_request
is more common convention.
Give embeders a chance to set up nvim, by processing a request before startup. This allows an external UI to show messages and prompts from --cmd and buffer loading (e.g. swap files)
This allows to properly handle first buffer swap message, as well as
errors in startup files and --cmd commands in an external UI starting nvim as a child, just by using
--embed-ui
option instead of--embed
Note: this does nothing that a
rpcrequest()
in a--cmd
and a corresponding handler in the UI client cannot do. But I think default matters, making a UI that has non-racy startup should be simple out of the box, rather than the UI needing to know details of the nvim startup process and event handling model even if it only ever wants to usenvim_ui_attach
andnvim_input
.