Deno: zsh completion problem

Created on 14 May 2020  路  8Comments  路  Source: denoland/deno

I installed deno with brew.

$ brew install deno
...
...
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
馃嵑  /usr/local/Cellar/deno/1.0.0: 9 files, 41.7MB
$ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2
$ deno --help

After created /usr/local/etc/zsh_completion.d/:

$ deno completions zsh > /usr/local/etc/zsh_completion.d/deno.zsh
$ source /usr/local/etc/zsh_completion.d/deno.zsh
_arguments:comparguments:325: can only be called from completion function

So how can I add shell completion?

I tried this but get the same output.

$ deno completions zsh > /usr/local/share/zsh/site-functions/_deno
$ source /usr/local/share/zsh/site-functions/_deno
_arguments:comparguments:325: can only be called from completion function
bug

Most helpful comment

For all oh-my-zsh users:
I assume $ZSH points to your ...../.oh-my-zsh/ installation.
The completion script needs to live in the $FPATH.
Ensure that $ZSH/completions is in $FPATH with echo $FPATH. This should be the case by default.

  1. create completions directory if not exists.
mkdir -p $ZSH/completions
  1. download deno code completion. (the _ is important)
deno completions zsh > $ZSH/completions/_deno
  1. force rebuild.
rm -f ~/.zcompdump*
  1. restart terminal.

@zemse This should also solve your permissions problem, because there are normally no root permissions required for this approach.

@marekkaczkowski rm the .zcompdump files could solve your problem

All 8 comments

Update

I miss understood the instruction doc
First I should generate zsh autocompletion script then put it in right path.
So what I am confused right now is that
isn't it the install script already said
zsh completions have been installed to: /usr/local/share/zsh/site-functions
So why bother generate new zsh autocompletion script manually?
If indeed need manually do so, what is the right path to redirect file?

#

old

Hi, I got some simlar problem.
After install deno, it mentions:
zsh completions have been installed to: /usr/local/share/zsh/site-functions
So I try do auto completion as
deno completions zsh > /usr/local/share/zsh/site-functions/_deno@
But it does not match or similar to the instructions of autocompletion for bash
which looks like
deno completions bash > /usr/local/etc/bash_completion.d/deno.bash
source /usr/local/etc/bash_completion.d/deno.bash
And I supposed bash shell autocomplete script should be pretty similar to zsh shell and there should be deno.zsh file ?

Anyone knows the right script for zsh shell for autocomplete feature in deno?

I think brew install deno handles the installing of completions for respective shells automatically. On the other hand, I did a manual install via curl with zsh as my shell.

deno completions zsh > /usr/share/zsh/site-functions/_deno

Running the above line of code was enough and completion is working now.

for me

$ deno completions bash >> ~/.zshrc

is working and I get deno auto completion

I installed deno with brew. The installation output did say that completions have been installed in in /usr/local/share/zsh/site-functions/_deno. I tried restarting the terminal app but still autocomplete is not working.

@leabstrait I tried doing deno completions zsh > /usr/share/zsh/site-functions/_deno, but I get:

zsh: operation not permitted: /usr/share/zsh/site-functions/_deno

Is it safe to change the permissions?

I installed deno with brew. The installation output did say that completions have been installed in in /usr/local/share/zsh/site-functions/_deno. I tried restarting the terminal app but still autocomplete is not working.

@leabstrait I tried doing deno completions zsh > /usr/share/zsh/site-functions/_deno, but I get:

zsh: operation not permitted: /usr/share/zsh/site-functions/_deno

Is it safe to change the permissions?

It's because writing into usr/share/zsh/ will need root permission.

Run this as root
# deno completions zsh > /usr/share/zsh/site-functions/_deno

I think this should work.

@leabstrait I forgot to mention that I tried using sudo but still it was giving error. Sorry for a dumb seeming question 馃槄

I was facing this issue on my laptop due to macOS System Integrity Protection.

% sudo deno completions zsh > /usr/share/zsh/site-functions/_deno
zsh: operation not permitted: /usr/share/zsh/site-functions/_deno

It needs to be removed if the above operation needs to be done on a mac. Just in case someone needs: https://stackoverflow.com/questions/32659348/operation-not-permitted-when-on-root-el-capitan-rootless-disabled

  1. I have completions at /usr/local/share/zsh/site-functions/_deno,
  2. when starting terminal deno completions does not work,
  3. BUT after running autoload -U compinit && compinit it works as expected :|,
  4. SO zsh runs autoload -Uz compinit && compinit from settings.zsh (to early, especialy if you're using oh-my-zsh) moving to plugins_after.zsh fixed my issue.

For all oh-my-zsh users:
I assume $ZSH points to your ...../.oh-my-zsh/ installation.
The completion script needs to live in the $FPATH.
Ensure that $ZSH/completions is in $FPATH with echo $FPATH. This should be the case by default.

  1. create completions directory if not exists.
mkdir -p $ZSH/completions
  1. download deno code completion. (the _ is important)
deno completions zsh > $ZSH/completions/_deno
  1. force rebuild.
rm -f ~/.zcompdump*
  1. restart terminal.

@zemse This should also solve your permissions problem, because there are normally no root permissions required for this approach.

@marekkaczkowski rm the .zcompdump files could solve your problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kyeotic picture kyeotic  路  3Comments

justjavac picture justjavac  路  3Comments

doutchnugget picture doutchnugget  路  3Comments

ry picture ry  路  3Comments

CruxCv picture CruxCv  路  3Comments