-
Notifications
You must be signed in to change notification settings - Fork 484
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Yash Thakur <[email protected]>
I'm wondering if this wouldn't fit better in the Cookbook. I'd like to see what @NotTheDr01ds thinks. |
I also agree, maybe we should rename the "External Completers" page to just "Completions" or "Completers"? |
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), | ||
} | ||
} |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Closes #1845