-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/zsh completion #2356
Feature/zsh completion #2356
Conversation
- cover main commands - detailed option for 'activate' to 'compiler' Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Signed-off-by: Sebastien Varrette <Sebastien.Varrette@uni.lu>
Hi @Falkor, this looks very useful! I actually created a bash completion file back in the day (see #459), but it wasn't accepted into Spack for various reasons. The main reason being that Spack is still under active development, and every time a new command is added or option flags are changed or renamed, it would need to be updated. Of course, I still use it every day and it works great for me. @tgamblin and I discussed this, and we think the best option moving forward would be to use argcomplete, a Python module that works together with argparse to determine what possible completions to use. This would have the benefit of working in all shells, and would allow complex spec analysis when doing a completion. See #459 for further discussion. |
OK, but unless I'm wrong, argcomplete, genzshcomp (I used to generate this completion file) and just like equivalent gems in the ruby world (I'm more familiar with) such as thor-zsh_completion does not render a full bullet-proof scheme after executions -- you always had to manually reparse the generated output as it is hard for it to catch subtilities on the commands generation.... Your back to a manual parse/update |
Hi @Falkor: Sorry for the long delay on responding to this! I think this could be very useful; thanks for submitting it! Is this ready to merge as-is or do you want to update things per @adamjstewart's #3026? |
Sourcing this should probably be added somewhere in |
And it should probably be in the same directory. At least that's where I put mine. |
I guess it can be merged as is. Compared to #3026, it add support for most fpath=(path/to/spack/contrib/completion $fpath) # OR fpath=(path/to/spack/share/spack/zsh $fpath) Thus I would suggest to complete SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# [...]
if [[ -n ${ZSH_VERSION-} ]]; then
fpath=("${SCRIPTDIR}" $fpath)
spack_zsh_completion_reload() {
unfunction _spack && autoload -U _spack
}
fi
|
@adamjstewart @trws @Falkor: Ok, #3026 is merged. Do any of you have time to tweak this PR so that it implements @Falkor's suggestion? I think the conditional he suggests for |
And thanks again to @Falkor for submitting this! |
I would try to tweak this, but I don't really know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is now more than 2 years old. I think the completion file needs a lot of adjustments.
@Falkor I'm going to close this PR as most of the commands and their flags are quite out of date. In the meantime, we've merged #14393 which provides a way to automatically generate most of the tab completion script. If you or anyone else want to submit a new PR to add zsh support, use #14393 as a reference and let me know if you have any questions. It should be as simple as adding a |
@adamjstewart sure, no problem and thx for the last guidelines. |
I was tired during the SC'16 tutorial to type all spack commands manually. So I decided to make a zsh completion file. As this is something new to me, it took me more time than planned and there are many rooms for improvement (in particular to handle automagically the specs) but I hope it would still be useful for the community.