Skip to content
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

Previewers/preloaders - ability to receive arguments #1657

Closed
2 of 3 tasks
0xkept opened this issue Sep 18, 2024 · 2 comments
Closed
2 of 3 tasks

Previewers/preloaders - ability to receive arguments #1657

0xkept opened this issue Sep 18, 2024 · 2 comments
Labels
invalid This doesn't seem right

Comments

@0xkept
Copy link

0xkept commented Sep 18, 2024

yazi --debug output

Yazi
    Version: 0.3.3 (Arch Linux 2024-09-05)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (Arch Linux 2024-09-05)

Emulator
    Emulator.via_env: ("foot", "")
    Emulator.via_csi: Ok(Foot)
    Emulator.detect : Foot

Adapter
    Adapter.matches: Sixel

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-1")
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: Some("0f594732b063a90d44df8c5d402d658f27471dfe_1726677924_1212395250")
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

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

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

Multiplexers
    TMUX               : false
    tmux version       : No such file or directory (os error 2)
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.3
    magick           : No such file or directory (os error 2)
    fzf              : 0.55.0
    fd               : 10.2.0
    rg               : 14.1.1
    chafa            : No such file or directory (os error 2)
    zoxide           : 0.9.5
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1


--------------------------------------------------

Please describe the problem you're trying to solve

Previewers/preloaders do not receive the args table. In my use case I would like the ability to pass the desired plugin to use for preloading/previewing, as My plugin is just a wrapper. Unless I am missing something, without this feature I would have to recompute the the mimetype( or use file extensions only ) for every file. Or create a separate plugin for each mimetype..

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

Possible solutions:

  1. Expose the args table as a variable so it can be used freely.
  2. Ability to define a custom method that receives the args table and returns the peek/seek/preload functions.
  • previewers = [
    { mime = "image/*", run = "plugin:method() --args='image'" },
    ]
local function method(self, args)
	local loader = loaders[args[1]]
	local preload = function(self)
		if condition() then return 1 end
		return loader.preload(self) and 1 or 2
	end
	return { preload = preload }
end
return { method = method }
  1. peek/seek/preload methods all receive the args table.
local function preload(self, args)
	local loader = loaders[args[1]]	
	if condition() then return 1 end
	return loader.preload(self) and 1 or 2
end
local function peek(self, args)
	local loader = loaders[args[1]]	
	if condition() then return end
	loader.peek(self)
end
return { preload = preload, peek = peek }

Additional context

Even though it may be better to have conditional previewer/preloader as a integrated feature eventually, I still think the ability to receive args could benefit even regular previewers/preloaders and is worth adding in.

Validations

  • I have searched the existing issues
  • The latest nightly build of Yazi doesn't already have this feature
@0xkept 0xkept added the feature New feature request label Sep 18, 2024
@0xkept 0xkept changed the title Previewers/preloaders - ability to receive arguments/ inherit state Previewers/preloaders - ability to receive arguments Sep 18, 2024
@sxyazi
Copy link
Owner

sxyazi commented Sep 18, 2024

Hi, it's already included in the Feature requests as "Previewer/preloader/fetcher support for passing parameters", closing as duplicate

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2024
@sxyazi sxyazi added invalid This doesn't seem right and removed feature New feature request labels Sep 18, 2024
Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants