completions/abbr: tweak completions for --function argument

Since the function argument now sticks to --function, we need to adjust
a condition.
This commit is contained in:
Johannes Altmanninger 2022-12-25 20:28:19 +01:00
parent 7340761b21
commit 53505c89dd

View file

@ -1,12 +1,6 @@
# "add" is implicit.
set __fish_abbr_not_add_cond '__fish_seen_subcommand_from --query --rename --erase --show --list --help'
set __fish_abbr_add_cond 'not __fish_seen_subcommand_from --query --rename --erase --show --list --help'
function __fish_abbr_add_function_cond
argparse h/help a/add p/position= f/function r/regex= 'set-cursor=?' \
-- (commandline -opc)[2..-1] 2>/dev/null
and test (count $argv) -eq 1
and set -q _flag_f
end
complete -c abbr -f
complete -c abbr -f -n $__fish_abbr_not_add_cond -s a -l add -d 'Add abbreviation'
@ -19,7 +13,6 @@ complete -c abbr -f -n $__fish_abbr_not_add_cond -s h -l help -d Help
complete -c abbr -f -n $__fish_abbr_add_cond -s p -l position -a 'command anywhere' -d 'Expand only as a command, or anywhere' -x
complete -c abbr -f -n $__fish_abbr_add_cond -s f -l function -d 'Treat expansion argument as a fish function'
complete -c abbr -f -n $__fish_abbr_add_cond -s f -l function -d 'Treat expansion argument as a fish function' -xa '(functions)'
complete -c abbr -f -n $__fish_abbr_add_cond -s r -l regex -d 'Match a regular expression' -x
complete -c abbr -f -n $__fish_abbr_add_cond -l set-cursor -d 'Position the cursor at % post-expansion'
complete -c abbr -f -n "$__fish_abbr_add_cond && __fish_abbr_add_function_cond" -a '(functions)' -d "Expand to output of this function"