use fzf based sorting instead of nushell buitin

This commit is contained in:
Juhan280 2026-07-02 02:15:12 +06:00
parent 5844cc609a
commit 5f0e47c5ee
1 changed files with 6 additions and 17 deletions

View File

@ -51,31 +51,20 @@ module zoxide_integration {
# #
def "nu-complete __zoxide_z" [context: string] { def "nu-complete __zoxide_z" [context: string] {
let ast = ast --flatten $context | skip 1 let ast = ast --flatten $context | skip 1 # skip the command name
# If the user has typed a space after the first argument, use the custom # If the user has typed a space after the first argument, use the custom
# completer. If not, use the built-in directory completion. # completer. If not, use the built-in directory completion.
if ($ast | is-empty) { return null } if ($ast | is-empty) { return null }
if $ast.0.span.end >= ($context | str length) { return null } if $ast.0.span.end >= ($context | str length) { return null }
let completions = ^zoxide query --exclude $env.PWD --list -- ...$ast.content ^zoxide query --exclude $env.PWD --interactive -- ...$ast.content
| lines | each { | str trim --right --char "\n"
if $in starts-with $"($homedir)(char psep)" { | if $in starts-with $"($homedir)(char psep)" { str replace $homedir "~" } else {}
str replace $homedir "~" | wrap display_override
} else {}
} | wrap display_override
| insert value { get display_override | debug --raw-value } | insert value { get display_override | debug --raw-value }
| insert span { start: ($ast | first).span.start, end: ($ast | last).span.end } | insert span { start: ($ast | first).span.start, end: ($ast | last).span.end }
| [$in]
{
options: {
sort: false,
filter: false,
case_sensitive: false,
completion_algorithm: "substring",
}
completions: $completions,
}
} }
{{ section }} {{ section }}