mirror of
https://github.com/denisidoro/navi.git
synced 2024-10-06 14:47:48 +03:00
c082c09935
This commit updates the legacy assignment and lambda syntax from the Elvish widget so it works on v0.17 without deprecation errors. This commit also refactors some of the code so it's cleaner.
30 lines
704 B
Plaintext
30 lines
704 B
Plaintext
use str
|
|
|
|
fn call-navi {
|
|
if (eq $edit:current-command '') {
|
|
var answer = (navi --print)
|
|
edit:replace-input $answer
|
|
} elif (not (str:contains-any $edit:current-command '|')) {
|
|
var answer = (navi --print --query $edit:current-command)
|
|
if (not-eq $answer '') {
|
|
edit:replace-input $answer
|
|
}
|
|
} else {
|
|
var @cmds query = (str:split '|' $edit:current-command)
|
|
var answer = (
|
|
if (eq $query '') {
|
|
navi --print
|
|
} else {
|
|
navi --print --query $query
|
|
}
|
|
)
|
|
|
|
if (not-eq $answer '') {
|
|
set cmds = [$@cmds $answer]
|
|
edit:replace-input (str:join '| ' $cmds)
|
|
}
|
|
}
|
|
}
|
|
|
|
set edit:insert:binding[Alt-h] = { call-navi >/dev/tty 2>&1 }
|