Skip to content

Send DDS event associated with a specific yazi instance #2648

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

Open
3 tasks done
mikavilpas opened this issue Apr 20, 2025 · 1 comment
Open
3 tasks done

Send DDS event associated with a specific yazi instance #2648

mikavilpas opened this issue Apr 20, 2025 · 1 comment
Labels
feature New feature request

Comments

@mikavilpas
Copy link
Contributor

yazi --debug output

Yazi
    Version: 25.4.8 (VERGEN_IDEMPOTENT_OUTPUT 2025-04-20)
    Debug  : false
    Triple : aarch64-apple-darwin (macos-aarch64)
    Rustc  : 1.86.0 (05f9846f 2025-03-31)

Ya
    Version: 25.4.8 (VERGEN_IDEMPOTENT_OUTPUT 2025-04-20)

Emulator
    TERM                : Some("xterm-256color")
    TERM_PROGRAM        : Some("WezTerm")
    TERM_PROGRAM_VERSION: Some("20250320-072107-a8735851")
    Brand.from_env      : Some(WezTerm)
    Emulator.detect     : Emulator { kind: Left(WezTerm), light: false, cell_size: Some((11, 23)) }

Adapter
    Adapter.matches    : Iip
    Dimension.available: WindowSize { rows: 90, columns: 347, width: 3817, height: 2070 }

Desktop
    XDG_SESSION_TYPE           : None
    WAYLAND_DISPLAY            : None
    DISPLAY                    : Some("/private/tmp/com.apple.launchd.wA0vos2gRs/org.xquartz:0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL           : Some("/bin/zsh")
    EDITOR          : None
    VISUAL          : None
    YAZI_FILE_ONE   : None
    YAZI_CONFIG_HOME: None
    YAZI_ZOXIDE_OPTS: None
    FZF_DEFAULT_OPTS: None

Text Opener
    default     : Some(OpenerRule { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-create: Some(OpenerRule { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-rename: Some(OpenerRule { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : tmux 3.5a
    tmux build flags   : enable-sixel=Unknown
    ZELLIJ_SESSION_NAME: None
    Zellij version     : 0.40.1

Dependencies
    file          : 5.41
    ueberzugpp    : 2.9.2
    ffmpeg/ffprobe: 7.1 / 7.1
    pdftoppm      : 25.02.0
    magick        : 7.1.1-43
    fzf           : 0.55.0
    fd/fdfind     : 10.2.0 / No such file or directory (os error 2)
    rg            : 14.1.1
    chafa         : 1.14.4
    zoxide        : 0.9.6
    7zz/7z        : 24.09 / No such file or directory (os error 2)
    jq            : 1.7.1

Clipboard
    wl-copy/paste: No such file or directory (os error 2) / No such file or directory (os error 2)
    xclip        : No such file or directory (os error 2)
    xsel         : No such file or directory (os error 2)

Routine
    `file -bL --mime-type`: text/plain


See https://yazi-rs.github.io/docs/plugins/overview#debugging on how to enable logging or debug runtime errors.

Please describe the problem you're trying to solve

I will try to explain my use case a bit:

I noticed that in yazi.nvim, pressing <tab> is the default key for "cycling buffers" - making yazi focus on the next open split window in neovim. This has worked fine for a long time, but currently yazi.nvim mappings are not that fancy - they completely hijack the tab key in this case and never send it to yazi.

I worked around this issue in mikavilpas/yazi.nvim#894 by allowing users (me) to define a yazi keymap for sending a custom DDS event using ya pub. yazi.nvim is able to react to this event and execute the action. This makes the <tab> key usable for other tasks and avoids the problem.

But I noticed that if I have two neovims open, and they both have a yazi open, pressing <tab> in one will execute the action in both editors 🙂

This is because yazi.nvim does not check what yazi session the event is associated with (all events are global). This is not a big problem right now, but eventually I would like to allow power users to define all yazi.nvim keymappings this way because the user experience is much better.

I know I could define my own protocol with either a --str or --json payload, but it might be an "easy win" to add this to yazi somehow.

Let me know what you think!

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

I am currently passing the --client-id flag when starting yazi so that I can ya emit-to commands to it (currently reveal and open only).

Do you think it would make sense to allow passing this flag to ya as well? It looks like the defaults are currently used here

Command::PubTo(cmd) => {
yazi_boot::init_default();
yazi_dds::init();
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, cmd.receiver, &cmd.body()?).await {
errln!("Cannot send message: {e}")?;
std::process::exit(1);
}
}

Additional context

No response

Checklist

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature
@mikavilpas mikavilpas added the feature New feature request label Apr 20, 2025
@mikavilpas
Copy link
Contributor Author

Actually I realized that --client-id needs to be hardcoded to the mapping because it's different each time. Maybe it could be read from an environment variable, but I'm not sure it's that useful to do anymore.

🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

1 participant