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

Move zoxide completer from external_completers to custom_completions #1847

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

blindFS
Copy link

@blindFS blindFS commented Mar 25, 2025

Closes #1845

@ysthakur
Copy link
Member

I'm wondering if this wouldn't fit better in the Cookbook. I'd like to see what @NotTheDr01ds thinks.

@132ikl
Copy link
Contributor

132ikl commented Mar 27, 2025

I'm wondering if this wouldn't fit better in the Cookbook.

I also agree, maybe we should rename the "External Completers" page to just "Completions" or "Completers"?

Comment on lines +79 to +90
def "nu-complete zoxide path" [context: string] {
let parts = $context | split row " " | skip 1
{
options: {
sort: false,
completion_algorithm: prefix,
positional: false,
case_sensitive: false,
},
completions: (zoxide query --list --exclude $env.PWD -- ...$parts | lines),
}
}
Copy link
Contributor

@132ikl 132ikl Mar 27, 2025

Choose a reason for hiding this comment

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

should we even specify the options here, or just provide the simplest example, and let users add the options if they desire?

ex:

def "nu-complete zoxide path" [context: string] {
  let parts = $context | split row " " | skip 1
  zoxide query --list --exclude $env.PWD -- ...$parts | lines
}

Copy link
Contributor

@fdncred fdncred Mar 27, 2025

Choose a reason for hiding this comment

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

I was thinking the same thing but, in this instance, I'd show both. One showing the minimal for comparison and then further down the "fancy" one to showing and describing the somewhat unknown trick of using options in the completer. Or maybe link to wherever options are documented, if they are.

Copy link
Contributor

@132ikl 132ikl Mar 27, 2025

Choose a reason for hiding this comment

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

I think linking to the options is a good idea (in a tip below the minimal example? we could also include the "fancy" version there). It looks like they're documented here.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm this actually seems to require positional: false to work, not entirely sure why

Copy link
Member

@ysthakur ysthakur Mar 27, 2025

Choose a reason for hiding this comment

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

Since Zoxide uses substring matching, positional: false makes it so that Nushell also does substring matching (which reminds me, we need a Substring matching algorithm rather than using positional). With plain prefix matching, even if Zoxide provides some completions, Nushell might filter them out because the prefix doesn't match. So I think the options are necessary for the completer to work for everyone.

I've been meaning to add an option to stop Nushell from doing any filtering and sorting of its own.

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.

Outdated external zoxide completer
4 participants