From af2daa7ab7dde3674f4861ef684773410b9cccd4 Mon Sep 17 00:00:00 2001 From: Christopher Boyd <6323077+cpboyd@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:06:28 -0400 Subject: [PATCH] feat(flutter): use up-to-date zsh completion (#11062) --- plugins/flutter/_flutter | 37 ------------------------------ plugins/flutter/flutter.plugin.zsh | 15 ++++++++++++ 2 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 plugins/flutter/_flutter diff --git a/plugins/flutter/_flutter b/plugins/flutter/_flutter deleted file mode 100644 index ab6ce4265..000000000 --- a/plugins/flutter/_flutter +++ /dev/null @@ -1,37 +0,0 @@ -#compdef flutter -#autoload - -local -a _1st_arguments -_1st_arguments=( - "analyze":"Analyze the project's Dart code." - "assemble":"Assemble and build flutter resources." - "attach":"Attach to a running application." - "build":"Flutter build commands." - "channel":"List or switch flutter channels." - "clean":"Delete the build/ and .dart_tool/ directories." - "config":"Configure Flutter settings." - "create":"Create a new Flutter project." - "devices":"List all connected devices." - "doctor":"Show information about the installed tooling." - "drive":"Runs Flutter Driver tests for the current project." - "emulators":"List, launch and create emulators." - "format":" Format one or more dart files." - "help":"Display help information for flutter." - "install":"Install a Flutter app on an attached device." - "logs":"Show log output for running Flutter apps." - "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers." - "precache":"Populates the Flutter tool's cache of binary artifacts." - "pub":"Commands for managing Flutter packages." - "run":"Run your Flutter app on an attached device." - "screenshot":"Take a screenshot from a connected device." - "test":"Run Flutter unit tests for the current project." - "upgrade":"Upgrade your copy of Flutter." - "version":"List or switch flutter versions." -) - -_arguments -C '*:: :->subcmds' - -if (( CURRENT == 1 )); then - _describe -t commands "flutter command" _1st_arguments - return -fi diff --git a/plugins/flutter/flutter.plugin.zsh b/plugins/flutter/flutter.plugin.zsh index 80b74f64a..44d196cd4 100644 --- a/plugins/flutter/flutter.plugin.zsh +++ b/plugins/flutter/flutter.plugin.zsh @@ -12,3 +12,18 @@ alias flrd="flutter run --debug" alias flrp="flutter run --profile" alias flrr="flutter run --release" alias flupgrd="flutter upgrade" + +# COMPLETION FUNCTION +if (( ! $+commands[flutter] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `flutter`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_flutter" ]]; then + typeset -g -A _comps + autoload -Uz _flutter + _comps[flutter]=_flutter +fi + +flutter zsh-completion >| "$ZSH_CACHE_DIR/completions/_flutter" &| \ No newline at end of file