Add cargo,completion.bash to clean_files.txt & run lint.

pull/1717/head
Nariyasu Heseri 2020-12-06 01:05:48 +09:00
parent 9e9edb9593
commit 2663071f14
2 changed files with 208 additions and 207 deletions

View File

@ -31,3 +31,4 @@ themes/powerline
# completions # completions
# #
completion/available/rustup.completion.bash completion/available/rustup.completion.bash
completion/available/cargo.completion.bash

View File

@ -3,7 +3,7 @@
# cargo (Rust package manager) completion # cargo (Rust package manager) completion
# This script is taken and modified from https://github.com/rust-lang/cargo/blob/master/src/etc/cargo.bashcomp.sh # This script is taken and modified from https://github.com/rust-lang/cargo/blob/master/src/etc/cargo.bashcomp.sh
if !_command_exists cargo; then if ! _command_exists cargo; then
return 0 return 0
fi fi
@ -11,7 +11,7 @@ fi
# Default bash version is 3.2 on latest macOS. See #6874 # Default bash version is 3.2 on latest macOS. See #6874
shopt -s extglob shopt -s extglob
_cargo() { __cargo() {
local cur prev words cword local cur prev words cword
_get_comp_words_by_ref cur prev words cword _get_comp_words_by_ref cur prev words cword
@ -156,12 +156,12 @@ _cargo() {
return 0 return 0
} }
complete -F _cargo cargo complete -F __cargo cargo
__cargo_commands=$(cargo --list 2>/dev/null | awk 'NR>1 {print $1}') __cargo_commands=$(cargo --list 2> /dev/null | awk 'NR>1 {print $1}')
__cargo_locate_manifest() { __cargo_locate_manifest() {
cargo locate-project --message-format plain 2>/dev/null cargo locate-project --message-format plain 2> /dev/null
} }
# Extracts the values of "name" from the array given in $1 and shows them as # Extracts the values of "name" from the array given in $1 and shows them as
@ -195,7 +195,7 @@ __cargo_get_names_from_array() {
fi fi
last_line=$line last_line=$line
done <$manifest done < $manifest
echo "${names[@]}" echo "${names[@]}"
} }
@ -234,7 +234,7 @@ __cargo_get_targets() {
if [[ "$line" =~ default|installed ]]; then if [[ "$line" =~ default|installed ]]; then
result+=("${line%% *}") result+=("${line%% *}")
fi fi
done <<<"$targets" done <<< "$targets"
echo "${result[@]}" echo "${result[@]}"
} }
@ -257,6 +257,6 @@ __cargo_toolchains() {
else else
result+=("+$line") result+=("+$line")
fi fi
done <<<"$toolchains" done <<< "$toolchains"
echo "${result[@]}" echo "${result[@]}"
} }