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

feat: add a way to use zoxide as an input field #654

Closed
wants to merge 1 commit into from

Conversation

diniamo
Copy link

@diniamo diniamo commented Feb 10, 2024

I'd appreciate it if we discussed this, before you make any changes.

Missing:

  • New default keybind for jump fzf
  • Fix the hang on line 55
  • Replace Err(anyhow!("")) with the correct way to create an empty error

Breaking changes:

  • jump zoxide now uses an input field, and the old functionality is moved to jump zoxide_interactive
  • Default jump fzf keybind is changed

let result = match opt.type_ {
OptType::Fzf => external::fzf(FzfOpt { cwd }).await,
OptType::ZoxideInteractive => external::zoxide(ZoxideOpt { cwd, query: None }).await,
OptType::Zoxide => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the anyhow errors are necessary.

@sxyazi might have a cleaner way but I can get this feature to work by copying how the input is used elsewhere:

				OptType::Zoxide => {
					tokio::spawn(async move {
						let rx = Input::_show(InputCfg::zoxide());
						let rx = Debounce::new(UnboundedReceiverStream::new(rx), Duration::from_millis(50));
						pin!(rx);

						while let Some(Ok(s)) | Some(Err(InputError::Typed(s))) = rx.next().await {
							if let Ok(url) =
								external::zoxide(ZoxideOpt { cwd: cwd.clone(), query: Some(s) }).await
							{
								Tab::_cd(&url)
							}
						}
					});
					return;
				}
				_ => return,
			};

Also minor but cargo +nightly fmt or rustfmt +nightly **/*.rs to format the Rust files.

@sxyazi
Copy link
Owner

sxyazi commented Feb 14, 2024

Thanks for your PR!

I plan to reimplement zoxide as a plugin to provide more flexibility, which will eventually deprecate the jump command, conflicting a bit with the content of this PR. I just haven't had the time to do it yet, but it should be soon ;)

@sxyazi
Copy link
Owner

sxyazi commented Apr 6, 2024

Hi, I've now reimplemented zoxide as a plugin in #865, which will allow users to copy it as a template and easily modify the commands inside.

That is, you can copy https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/zoxide.lua as your ~/.config/yazi/plugins/zoxide.yazi/init.lua, and then call ya.input() to receive the user's input, and passes it to the zoxide command - Yazi will load your own zoxide.yazi plugin automatically

@sxyazi sxyazi closed this Apr 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants