Skip to content

feat: replace fzf with skim as the default chooser#2855

Open
bestgopher wants to merge 1 commit intocasey:masterfrom
my-contributes:choose
Open

feat: replace fzf with skim as the default chooser#2855
bestgopher wants to merge 1 commit intocasey:masterfrom
my-contributes:choose

Conversation

@bestgopher
Copy link
Copy Markdown

@bestgopher bestgopher commented Aug 8, 2025

Closes: #939

2025-08-08.17.20.26.mov

@bestgopher bestgopher force-pushed the choose branch 2 times, most recently from 88885fc to 0c74cd6 Compare August 8, 2025 08:55
@bestgopher
Copy link
Copy Markdown
Author

I don't know how to fix some test case errors.

@bestgopher
Copy link
Copy Markdown
Author

@casey When you have a chance, could you take a look.

Copy link
Copy Markdown
Owner

@casey casey left a comment

Choose a reason for hiding this comment

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

Sorry for letting this sit. See comments!

@@ -0,0 +1,127 @@
use crate::config::Config;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

You can use use super::* and get rid of a lot of these imports.


impl<'a> Chooser<'_, 'a> {
fn run_with_command(self, recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {
let Self::Command {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I would pass these arguments in instead of taking self.

Ok(recipes)
}

fn run_with_skim(recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
fn run_with_skim(recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {
fn choose_with_skim(recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {

}

impl<'a> Chooser<'_, 'a> {
fn run_with_command(self, recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
fn run_with_command(self, recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {
fn choose_with_command(self, recipes: Vec<&Recipe>) -> Result<Vec<String>, Error<'a>> {

let options = SkimOptionsBuilder::default()
.height(String::from("100%"))
.multi(true)
.preview(Some("just --unstable --color always --show {}".to_string()))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'd like to avoid a recursive call here. Can we pass in both the items and their previews?


// `run_with` would read and show items from the stream
let selected_items =
Skim::run_with(&options, Some(items)).map_or_else(Vec::new, |out| out.selected_items);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We should not swallow errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default to using skim as library when invoking chooser, to avoid dependency on fzf being installed

2 participants