unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Brice Waegeneire <brice@waegenei.re>
To: Reza Alizadeh Majd <r.majd@pantherx.org>
Cc: Help-Guix <help-guix-bounces+brice+lists=waegenei.re@gnu.org>,
	help-guix mailing list <help-guix@gnu.org>
Subject: Re: guix completion in zsh
Date: Tue, 02 Jun 2020 13:59:01 +0000	[thread overview]
Message-ID: <140372893f70a6ef57ddf513a4ee05a0@waegenei.re> (raw)
In-Reply-To: <20200530105121.46c1ae3d@pantherarch.localdomain>

Hello Reza,

On 2020-05-30 06:21, Reza Alizadeh Majd wrote:
> On Tue, 26 May 2020 23:14:01 +0200
> Ludovic Courtès <ludo@gnu.org> wrote:
> 
>> I think you need to make sure the Zsh completion file for Guix is
>> sourced.
>> 
> 
> Thanks for you response, what is the right location to find this "Zsh
> completion file"? is it installed during installation of `zsh` package?

I had the same issue since I switched to Guix but I didn't took the time 
to look into it before.

I just submitted a patch[0] that add
"/run/current-system/profile/share/zsh/site-functions" to $fpath, so 
system
packages will get completions. To get completions from user profile, I
added the following to my system configuration:

--8<---------------cut here---------------start------------->8---
(define %zshrc
   (plain-file "zshrc"
               "\
fpath+=($HOME/.guix-profile/share/zsh/site-functions)
"))

(operating-system
   …
   (services (list …
                  (simple-service 'zshrc etc-service-type
                    (list `("zshrc" ,%zshrc))))))
--8<---------------cut here---------------end--------------->8---

When $fpath is properly set, the user only have to run “autoload -Uz
compinit && compinit” or add it to it's '~/.zshrc' to enable 
completions.

I don't know how to add completions when using “guix environment”
especially when executed multiple times in a shell since 
GUIX_ENVIRONMENT
get replaced each time it's executed.

Also note that the ZSH completion for 'guix' has never been updated in 4
years so it's missing quite a few commands and options while 
'guix-daemon'
completion doesn't exists. So you get completions as nice as the ones 
from
bash.

I tried updating zsh's completions but I didn't went far because it's
tedious since it's a lot of copy pasting from “guix --help”. So to get
proper completion support for zsh a better solution would be to use the
bash completions as they are parsed from “guix --help” directly instead 
of
being copy-pasted and that zsh provide a bash compatible completion 
system
trough 'bashcompinit'. But unfortunately our bash completions have some
bashism that zsh can't understand, especially the 'compopt' built-in. 
You
can try to use bash completion in zsh by running “autoload bashcompinit 
&&
bashcompinit && source ./etc/completion/bash/guix” but you will end up 
with
half broken completions.

[0]: https://issues.guix.info/issue/41662

- Brice


      parent reply	other threads:[~2020-06-02 15:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-24 11:35 guix completion in zsh Reza Alizadeh Majd
2020-05-26 21:14 ` Ludovic Courtès
2020-05-30  6:21   ` Reza Alizadeh Majd
2020-06-01 16:10     ` Dmitry Alexandrov
2020-06-02 13:59     ` Brice Waegeneire [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=140372893f70a6ef57ddf513a4ee05a0@waegenei.re \
    --to=brice@waegenei.re \
    --cc=help-guix-bounces+brice+lists=waegenei.re@gnu.org \
    --cc=help-guix@gnu.org \
    --cc=r.majd@pantherx.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).