Adding support for Wasp completions in zsh
#964
Replies: 3 comments 1 reply
-
I've go this working for me (it's pretty basic, since I'm new to zsh completions). file: fpath=($fpath ~/.completions) file: #compdef _wasp wasp
function _wasp {
local line
_arguments -C \
"1: :(new version waspls completion start db clean build telemetry deps dockerfile info)" \
"*::arg:->args"
case $line[1] in
new)
_wasp_new
;;
db)
_wasp_db
;;
esac
}
function _wasp_new {
_arguments \
"1:project name:"
}
function _wasp_db {
_arguments \
"1: :(migrate-dev studio)"
} |
Beta Was this translation helpful? Give feedback.
-
Nice explanation! I think we should be looking into solution number one -> go with bash autocompletion and just piggy back on it for zsh. As you said, we can ask users what they use, then give them correct instrutcions / do correct actions, and that is it. Regarding the bash script you wrote -> I would rather we don't have duplicated logic for autocompletion. Right now we actually don't have much logic at all even in bash -> all logic is in Haskell, and bash just proxies it. So we really want sometihng simlar with zhs. Piggybacking on bash sounds like the best trade off between speed and what we get. |
Beta Was this translation helpful? Give feedback.
-
I use a similar script but reusing bash completion functionality. #compdef wasp
local completions
local completion
IFS=$'\n' completions=($( COMP_LINE=$words wasp completion:list ))
for completion in $completions; do
compadd -- $completion
done But the bash completion now needs some improvement. Switching to |
Beta Was this translation helpful? Give feedback.
-
We currently have
bash
completions support withwasp completion
andwasp completion:generate > <your-chosen-directory>/wasp-completion
.wasp/waspc/cli/src/Wasp/Cli/Command/BashCompletion.hs
Line 16 in 2ed921a
These completions are
bash
specific and don't work withzsh
(default shell for our MacOS users). The user needs to add the following to their.zshrc
to add support forbash
-like completion:We want to make our
completion
command aware that there are two different shells and help users withzsh
to setup Wasp completions. The command should allow user to select which shell he uses and get the proper info how to setup completions.For example,
wasp completion zsh
would instruct user withzsh
how to setup completions.We could take two routes:
bash
completions and instruct user how to enable it forzsh
(quick and dirty)zsh
completions code (proper way to do it details)Beta Was this translation helpful? Give feedback.
All reactions