-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(remote): add wait subcommands #17856
base: master
Are you sure you want to change the base?
Conversation
runtime/lua/vim/_editor.lua
Outdated
vim.api.nvim_command(table.concat(command, ' ')) | ||
if flags['wait'] then | ||
vim.api.nvim_create_augroup('_remote_' .. chan_id, {}) | ||
vim.api.nvim_create_autocmd('BufUnload', {callback=function() |
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'll need to wait till all the open bufs are unloaded, not just the first one.
end | ||
vim.fn.rpcrequest(rcid, 'nvim_command', table.concat(command, ' ')) | ||
local remote_chan_id = vim.fn.rpcrequest(rcid, 'nvim_get_api_info')[1] |
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 is a silly way to get the channel id for the remote side to callback with. I couldn't see a way to do that from the remote side though. Is there a way from inside an RPC to get the channel id for the other side of the connection? If not, would it make sense for me to add that?
src/nvim/main.c
Outdated
if (wait) { | ||
// If we're just waiting for the remote server to let us know editing is complete, flip flags | ||
// to get us to listen for its response in as lightweight a way as possible | ||
params.use_vimrc = "NONE"; |
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.
Really I'd like to start the main loop enough to handle incoming RPC calls to say when I should exit. This works for that, but it's a little indirect. Is there a more direct way to kick off the main loop and do nothing else?
I have tested the feature as git commit editor with neovim terminal, but neovim is launched within neovim terminal. |
Maybe this can be used:
|
I use it, but it launches within neovim terminal... |
@Shougo Thanks for trying it out! Is the failure a regression with this PR, or is it failing with just the code on master? If it's failing on master, would you mind opening an issue, answering the below questions, and tagging me? I'd like to keep this PR focussed on changes in the PR. In either case, a few more pieces of info would be helpful for me looking into this:
|
I have tested the PR. Because in master wait feature is not implemented yet. I have tested it with neovim built in terminal. I have set When Note: I have tested it in Alacritty terminal. But I think it is same with neovim GUI client. |
Note: I use |
It seems new instance in the terminal. But you can test it easily.
No error messages. I think it is not error. |
@Shougo What are you setting For it to connect to the pipe you're creating in the Also, using silent is going to suppress any warning about not being able to connect. Could you try with |
I use
I have tested it. No error messages. |
I'm wondering about the other side of the connection i.e. where you specify |
Yes. I have set and it works. Because the editor is executed in the neovim terminal. Oh no. I have tested it by deol.nvim. https://github.com/Shougo/deol.nvim/blob/master/autoload/deol.vim#L238 |
Hm.... It seems the server feature does not work.
And
It does not work. Because |
To test this, your server starting command, For the client, use this command:
Note that clean is moved before the remote command. Since remote treats the arguments after it like files, later arguments are ignored when sending files remote. Most importantly, note that it's using After starting the server like that, please run If that shows any errors, I'd also appreciate it if you could test on master and see if the same thing shows up. Since this branch is still under development, I may have broken something here. |
I don't quite understand why we need all of the random variants of Vim's |
@groves Hi. I have tested it.
Why it is failed?
Please see my command line. |
I'd also lose the tab and silent variants if I were designing this from scratch. I see keeping the variants as allowing ease of migration from Vim and to allow people to write scripts and instructions that work for both. This feels like part of the API that we keep in the same way that we keep a bunch of clunky bits of Vimscript and builtin functions. |
@Shougo My guess would be that the server is failing to listen on that pipe. In the server instance you're running with This does make me wonder if we should have a user visible message if we fail to start the server on an address given in |
OK. I get it. It seems works. If I open the file by I think local neovim must wait until remote neovim file is closed like neovim-remote. |
I think |
4eac586
to
d4f507b
Compare
This is a bug I introduced on this branch. Should be fixed now. Thanks for finding it! Feel free to give that fix a try, but I should warn you that there are likely to be other issues. I still have a few things I need to address before bumping this PR from draft to ready. |
Oh, thank you for the fix. I will try again later. |
The feature is broken now...
|
Such a migration won't work except for trivial cases. So I'm not seeing a strong reason to add anything more than |
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.
Before continuing with this, I'd like to see a table comparing the equivalent --remote foo
command to the --remote-foo
variant. For example:
Legacy (Vim) | Minimal (Nvim, with always-blocking --remote ) |
---|---|
--remote-send "foo" | --remote "call nvim_input('foo')" |
--remote-wait "foo" (blocking) | --remote "foo" |
--remote "foo" (nonblocking) | --remote "call timer_start({-> foo})" |
--remote-blah | --remote "blah" |
We should not add things just because Vim did it. There needs to be a good reason.
- The Lua/Vimscript API has many more features today than it did when Vim added these things.
- Providing examples of using Lua/Vimscript helps users understand and connect concepts.
- Likewise, providing shallow "sugar" that does very little, actually harms users by increasing the burden of useless "knowledge" and decreasing the weight of composable concepts (the API).
This makes a perfect sense to me if Neovim were a new editor. In that scenario, the best thing for users is to have a clear path from starting out to mastery of a simple, powerful set of customization tools. In my understanding, Neovim's scenario has more nuance. At least as I've internalized Neovim's values, one of those is an easy transition for Vim users. That doesn't invalidate your point about helping users towards the best Neovim tools, but it adds a possibly conflicting desire to make existing Vim idioms and APIs work well. Like with any big project, there are even more competing desires for Neovim's direction. To complete the picture as I understand it, this is what I roughly see as the Neovim desires in order of importance:
I'm not laying these out here to try and convince you that those are the right desires. I'm really trying to elicit what the desires are as envisaged by the Neovim maintainers. My having a better sense of the desires will help me make proposals that better track with those desires. If that's already on the web somewhere that I haven't seen, a link to that is plenty good. What you're suggesting about comparing the Vim approach with a minimal Neovim approach makes sense to me as a way to decide if and how to proceed with this. I'd like to add in how well each of those items fit with the overall desires to make it a complete picture. |
Not speaking for the rest of the team here, but I don't think
is really a strong project goal (anymore). What we do care about is backwards compatibility for the plugin ecosystem, so Neovim users can still use Vim plugins (even though they themselves are not expected to use legacy syntax, if better alternatives exist). So (only) if not supporting a particular Vim option would break a useful plugin, that would count as a valid argument in favor of including it. But that should be a concrete example. |
That doesn't apply to
However, the table that I requested above, will be useful as:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Re-read my previous comments. I've no objection to So to be clear, I'm suggesting that |
Oh, I see! Thank you so much for clarifying, was confused after 0.7 shipped a non-blocking |
That was exactly my usage of I don't understand the use of the tab and silent variants, and the send and expr variants are silly in the light of Neovim's API. I have no concern with dropping those, though as @jcorbin pointed out, the non wait versions of all of them shipped in 0.7. They add almost no code compared to the bulk of stuff needed for As it stands, there's a functional version of the wait variations on this branch now. I was planning on adding a couple more tests and finishing up the docs before marking it ready for review. I'm happy to finish it up if someone wants to write up a design for where this should end up. I'm also perfectly happy if someone else wants to take it from here. |
If the same features are works, I don't need subcommands yeah. But I want to use neovim remote feature as In It works as expected in It does not work in neovim remote features.
So I need the feature. |
The main cost is the user interface (which includes documentation, and noise in Waiting to see the table requested in #17856 (review) |
Please see below table.
I think wait variants and |
This still needs more tests and handling of waiting for multiple edits. I was hoping to get some feedback on the approach in general as I work on those pieces.