-
Notifications
You must be signed in to change notification settings - Fork 375
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
Increase possibilities for yazi<->embedding editor integration #989
Comments
If Neovim doesn't provide an API for reading
I'm not quite sure what you mean by "loading" plugins. Normally, Yazi plugins don't need to be manually loaded; they are lazily loaded automatically after user actions (such as pressing a key). Are you referring to the initialization process of plugins? If so, that would involve loading an |
I love this idea. I think I will try it out soon.
I'm not sure if "plugin" is the correct term to use here. I'm looking for a way to
|
Tried this approach, but I quickly found out yazi could not be started when it's "hidden", possibly because it cannot draw to a screen. Opened #1004 which could be used to work around this limitation - the idea is to start |
In comparison to the LSP (language server protocol) which uses json RPC (https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/), several types of messages are supported:
Right now, the Is this a direction you could see yazi going? |
It sounds like the three modes you mentioned are already covered by the current DDS, but it's based on an asynchronous publish-subscribe model rather than a synchronous request-response model. For example, for the first mode, |
Message passing with the DDS itself should not be an issue. My issue is that there is no known real time communication channel that I could use from neovim. It's becoming clearer and clearer to me that at some point yazi.nvim might need its own plugin for various features. I will think about this idea more. Maybe there's something that could be done on the plugin level to make the communication possible. |
I think adding a new
Could you describe your needs? What are the things that DDS currently can't provide directly and must be done through plugins? |
Actually, I'm coming around to #1004 being a good approach. Let's reopen it and see if we can finish it. Previously I was confused about a few things, but I think this approach can work for me:
I will think about what the best way to include the plugin would be.. For example, when running yazi inside neovim, some keybindings should probably run plugin specific functionality, but when running outside of neovim they should use the default functionality instead. Have you thought about this kind of an approach? |
I've also played with this issue because I'm using Nushell, but Starting the second process with |
Please try #1004 to see if it meets your needs. |
Could you give me an example - which keys need to trigger a specific plugin inside Neovim and when? |
Sure, I was thinking good use cases might be to
Other use cases for this type of integration are also possible (when yazi is open in neovim):
There's lots of cool ideas that I think this could help with! |
I need to think more about an elegant way for the plugin to take over these keybindings. Do you have any ideas on this? |
Yes, I have a couple of ideas 🙂
Neovim is a special case though, because I control both the (future) plugin as well as the invocation of yazi itself. Maybe idea 2 could be more useful to the yazi community. I think it might allow some plugins to provide a more "batteries included" type of experience (reducing the amount of manual configuration). |
this feels like an |
I tried this yesterday and found that the issue isn't due to nested Neovim instances (as I mentioned here). Instead, it's because yazi.nvim starts Yazi with Do you think this could be solved using the existing
Can you elaborate on this? I don't quite understand why splits in Neovim would be related to Yazi's default key bindings. From what I understand, you want to add a new
I'm not too satisfied with these two ideas (I'll explain why later), so I want to see if we can solve these issues using existing solutions first. If they don't work, we can look for other ways. |
Do you think this could be solved using the existing error: unrecognized subcommand 'sub'
tip: a similar subcommand exists: 'pub'
Usage: ya <COMMAND>
For more information, try '--help'. version: Yazi 0.2.5 (Arch Linux 2024-04-27) |
Even though I think it's doable, there are still some concerns:
It's simply not feasible: To achieve the highest performance, Yazi's configurations are designed to be immutable. They are parsed and initialized only once at startup. So dynamically registering new content into the configuration via the Lua API isn't feasible. To achieve this, we would need to change the immutable configuration and event dispatch design, introduce more locks and memory clones, which would increase code complexity and decrease performance. |
It was added two weeks ago in #1004 and will soon be released as part of Yazi v0.3. |
I think this sounds like a really good idea. I will have to do some experiments but I think this can probably work as long as plugins such as https://github.com/willothy/flatten.nvim are disabled e.g. when |
Yeah I think I meant a merging of additional yazi.nvim settings with the ones that are used in the terminal yazi. I'm not really sure what exactly would be required, but since there are 3 configuration files it would perhaps add quite a bit of complexity. I think you laid out the challenges in yazi related to this level of configuration quite well; perhaps it's better to abandon this idea. Maybe it would be possible to do overriding or configuration merging in yazi.nvim though. |
I'll summarize a bit, although you are already aware of some of these points:
|
Awesome! Thanks for your excellent work, it's great to see most issues being resolved through
Do you mean opening three tabs in Yazi or Neovim?
Yazi generates a unique ID on startup and sets it as the env variable The plugin would need to ensure it always generates a globally unique ID; using a nanosecond timestamp is a good method. I've been considering introducing new builtin events, like a
which would automatically load and run the |
I mean opening tabs in yazi, based on the files that are open in neovim.
I love it, it's somehow beautiful - a bit like ☯︎
I think reading the environment from another process is not possible, but I really like passing it as a parameter. I can maybe PR this at some point.
Ooh this is an amazing idea. If I understand this correctly, it would enable sending any of the built-in commands to yazi through This could potentially solve both of the remaining open questions at the same time. |
As discussed in sxyazi#989 (comment), this will allow applications embedding yazi to set the YAZI_ID environment variable to a known value. Afterwards, the application can use this id with `ya pub` to publish messages to the specific yazi instance.
This is a technical change with no change in features for the end user. Right now you can opt in to trying it out by setting `use_yazi_client_id_flag = true` in your config (run `:checkhealth yazi` afterwards). This will probably be the default mode of communication in the future. Before this change, real time communication with the embedded yazi instance has been possible, but it has had some limitations: - yazi.nvim had the possibility of sending commands to yazi, but the communication has been global, meaning that all yazi instances running on the system have been able to receive these messages. This has been too dangerous to implement, as making yazi do any actions could have unintended side effects if multiple yazis execute the same actions, potentially in different directories on the system. - similarly, receiving events from yazi has been limited to receiving events from all yazis running on the system. This has not been a problem so far since the events we use (rename, delete, trash, move, cd, hover, bulk) are not dangerous, and typically the user only focuses on one yazi.nvim instance at a time anyway. This change removes this limitation from future features by giving the yazi instance shown by this plugin a unique identifier. This identifier can later be used to send and receive messages with this specific yazi instance. See these for more information and context: - sxyazi/yazi#989 (comment) - sxyazi/yazi#1305
This is a technical change with no change in features for the end user. Right now you can opt in to trying it out by setting `use_yazi_client_id_flag = true` in your config (run `:checkhealth yazi` afterwards). This will probably be the default mode of communication in the future. Before this change, real time communication with the embedded yazi instance has been possible, but it has had some limitations: - yazi.nvim had the possibility of sending commands to yazi, but the communication has been global, meaning that all yazi instances running on the system have been able to receive these messages. This has been too dangerous to implement, as making yazi do any actions could have unintended side effects if multiple yazis execute the same actions, potentially in different directories on the system. - similarly, receiving events from yazi has been limited to receiving events from all yazis running on the system. This has not been a problem so far since the events we use (rename, delete, trash, move, cd, hover, bulk) are not dangerous, and typically the user only focuses on one yazi.nvim instance at a time anyway. This change removes this limitation from future features by giving the yazi instance shown by this plugin a unique identifier. This identifier can later be used to send and receive messages with this specific yazi instance. See these for more information and context: - sxyazi/yazi#989 (comment) - sxyazi/yazi#1305
This was completed in #1443.
This was completed in #1305 – thanks for contributing it!
There's now a new issue to track this, #1610, and it might eventually become a new subcommand I think this issue can now safely be closed :) 🚀🚀🚀 |
I'm going to lock this issue because it has been closed for 30 days. ⏳ |
Please describe the problem you're trying to solve
In https://github.com/mikavilpas/yazi.nvim, I have ideas for some features that I think might require allowing a deeper level of interaction with editors that want to embed yazi:
Would you be willing to contribute this feature?
Describe the solution you'd like
Suggestions
Suggestion 1: programmatic access to yazi actions
The api could be disabled by default, and enabled with a command line flag such as
yazi --enable-rpc-api
, maybe even enabled in the user's configuration.Currently, yazi can send events via the data distribution service (dds), and the editor integrations can listen to these events. Events can also be sent to yazi via
ya pub
andya pub-static
.Even though the communication is now bidirectional, there are some difficulties with this approach:
m actions * n plugins
while there could bem actions + n plugins
if they were implemented once in yaziSuggestion 2: allow loading additional plugins from the command line
With deeper integration between yazi and neovim, some features only make sense when both yazi and neovim are running. I love the fact that yazi is a very composable tool and I can run it from the terminal as well as in my editor.
I want myself and other users to have a good experience in both environments. I think the best way to do this would be adding a new flag such as
yazi --load-plugin='~/.local/share/nvim/lazy/yazi.nvim/bundled-yazi-plugin/'
which would load this additional plugin that provides yazi.nvim specific functionality. When runningyazi
in the terminal environment, the plugin would not get loaded.Additional context
Benefits and ideas
Finally, I want to list some ideas and benefits that I think would come from these changes:
The text was updated successfully, but these errors were encountered: