mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 01:51:14 -03:00
Speed up rustc completions, filter out deprecated options
Don't unconditionally execute the plumbing to get `rustc -C` completions (use it only when trying to complete `rustc -C`), filter out deprecated options, and use fewer calls to the `string` builtin to optimize further. Need to do the same thing for the `-Z` completions next, those hang the shell for a good 1.5+ seconds.
This commit is contained in:
@@ -28,17 +28,7 @@ complete -c rustc -f -l extern
|
|||||||
complete -c rustc -f -l sysroot
|
complete -c rustc -f -l sysroot
|
||||||
complete -c rustc -x -l color -a 'auto always never'
|
complete -c rustc -x -l color -a 'auto always never'
|
||||||
|
|
||||||
set -l rust_docs (rustc -C help 2>/dev/null \
|
complete -c rustc -s C -l codegen -xa "(rustc -C help 2>/dev/null | string match -rv 'option is deprecated' | string replace -rf -i '(\s+)-C\s*(.+)=val(\s+)--(\s+)([^\n]+)' '\$2='\t'\$5')"
|
||||||
| string replace -r -i '(\s+)-C(.+)(\s+)--(\s+)([^\n]+)' '$2 $5' \
|
|
||||||
| string trim \
|
|
||||||
| string match -r '^.*[^:]$')
|
|
||||||
|
|
||||||
for line in $rust_docs
|
|
||||||
set -l docs (string split -m 1 ' ' -- $line)
|
|
||||||
set -l flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
|
|
||||||
$docs[1])
|
|
||||||
complete -c rustc -x -s C -l codegen -a (string escape -- "$flag") -d "$docs[2]"
|
|
||||||
end
|
|
||||||
|
|
||||||
# rustc -Z is only available with the nightly toolchain, which may not be installed
|
# rustc -Z is only available with the nightly toolchain, which may not be installed
|
||||||
if rustc +nightly >/dev/null 2>&1
|
if rustc +nightly >/dev/null 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user