| CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(excmd): add ":restart" command #33953
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
This comment has been minimized.
This comment has been minimized.
643fe1e to
2f1cb47
Compare
e0217fa to
438db85
Compare
52db88e to
1d3cd86
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
With that I think I'll open it up for review while I try and fix the functionaltest error |
1d3cd86 to
e87e745
Compare
99d685c to
21fcae8
Compare
21fcae8 to
267ed84
Compare
| it. This fails when changes have been made | ||
| and Vim refuses to |abandon| the current buffer. | ||
|
|
||
| :restart! |
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.
off-topic / non-blocker:: imo this is an uninteresting use of "!" (although common). Users can always do :wall to save everything before restart. And :confirm restart to opt-in to confirm "unsaved changes".
We might want to use "!" to mean "don't restore state/session" or something like that.
Don't need to figure this out right now.
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.
Tried this locally, it works. Super cool, thanks @sathya-pramodh!
The "shape" looks good. Only some minor comments then let's merge it!
- add to news.txt "features" section! Either in "Editor" or "UI" section.
RestartPreandRestartPostautocmd hooks for doing ":mksession
I would expect the normal VimEnter/VimLeave to work. I don't see why we would treat :restart specially? Maybe I'm wrong though.
| // 2. Close ui client channel (auto kills the `nvim --embed` server due to self-exit). | ||
| const char *error; | ||
| bool success = channel_close(ui_client_channel_id, kChannelPartAll, &error); |
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.
FUTURE: we might want to give more control over how the server is stopped. E.g.:
:restart +qall
(similar to :help +cmd). This also frees up "!" to be used for some other purpose.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
Hmmm I would have to try this out.... |
|
|
|
I suggest waiting on that until a followup PR. It shouldn't block this one. The only tiny blockers here are
Added missing docs in #34261 . |
|
I also added a "Note:" for #33953 (comment). That'd be okay right? |
267ed84 to
92f4248
Compare
ad5eaf0 to
bf63f3d
Compare
I would say that a way to distinguish "normal" and "restart" events would be useful. I see the main use case is to write temporary |
| } | ||
|
|
||
| // Send an ui restart event. | ||
| ui_call_restart(); |
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.
This presumably sends the event to all UIs. But we should only send to the "current UI". See ex_detach for how to get the current UI.
Also, should the server explicitly detach all other UIs?
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.
At most one UI can restart the server
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.
Can the UI event reach multiple UIs? If so, how will each UI know whether to attempt restart?
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.
A UI knows whether it is the one that started the server in the first place. Only that UI can stop the server and then restart it. Other UIs can't stop the server at all.
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 ui_client_event_restart be invoked on each UI? If so, we're depending on channel_close(ui_client_channel_id,...) to fail I guess?
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.
But a non-embedding client does not know what arguments the server was started with, so it still can't restart the server...
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.
Yeah that'd need to be handled... We could do something similar to v:argv by setting another global and using that for both the embedded case and the remote case
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.
Why can't we just only send the restart UI event to the "current UI", like how :detach works?
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 can a client restart the server if it doesn't know how the server was started?
- If one client restarts the server, shouldn't the other clients have to know that they need to reattach?
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 can a client restart the server if it doesn't know how the server was started?
As long as client+server are on the same machine, v:argv gives the info needed to restart, no? (Maybe also need to think about environment variables and file handles, but that can be a "revisit later" topic.)
If the server is "remote" and not restartable, we should show an error and cancel the :restart.
If one client restarts the server, shouldn't the other clients have to know that they need to reattach?
The current spec for this feature is that all other clients will just detach, not reattach. Reattaching all the clients is a "nice to have" that in practice may not be a common use-case.
Tracked in #34296
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Problem: ":restart" always executes ":qall" on the server in order to exit it. neovim#33953 (comment) Solution: Add an arg to ":restart" as ":restart +cmd" to control how the server exits.
Developing/troubleshooting plugins has some friction because "restarting" Nvim requires quitting, then manually starting again, in some fashion.
Implement a ":restart" command which:
nvim --embedserver.nvim --embedserver and attaches to it.Fixes: #32484