scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Completions not working in zsh when oh-my-zsh isn't installed

Open wleczny opened this issue 3 years ago • 3 comments

Version(s)

0.1.9

Describe the bug

After scala-cli install completions I had this error message in terminal every time I run it:

/Users/username/.zshrc:4: command not found: compinit

Adding these 2 lines at the beginning of .zshrc file solved the case:

autoload -Uz compinit
compinit

It would be nice to get information what should I do during scala-cli completions installation.

Moreover scala-cli completions don't work for me after all these steps. I am using macOS with M1 Pro.

wleczny avatar Jun 30 '22 11:06 wleczny

It works for me locally (macOS too, but Intel one). Do you use oh-my-zsh? I'm using it, I'm wondering whether some of its setup (beyond the compinit stuff you mentioned) is required…

alexarchambault avatar Jun 30 '22 16:06 alexarchambault

Installing oh-my-zsh did the work, thanks!

wleczny avatar Jul 01 '22 09:07 wleczny

Ideally, we should ensure it works even without oh-my-zsh…

alexarchambault avatar Jul 01 '22 13:07 alexarchambault

I have oh-my-zsh but completions still don't work.

$ scala-cli e
(eval):5: unmatched '
(eval):5: unmatched '
(eval):5: unmatched '

The problem seems to be with those escaped ' characters:

$ scala-cli complete zsh-v1 "1" "e"
local -a args306746944
args306746944=(
'export:The \'export\' sub-command is experimental.'
)
_describe command args306746944
$ eval "local -a args306746944
args306746944=(
'export:The \'export\' sub-command is experimental.'
)
_describe command args306746944"

zsh: unmatched '


$ eval "local -a args306746944
args306746944=(
'export:The export sub-command is experimental.'
)
_describe command args306746944"

_tags:comptags:36: can only be called from completion function
_tags:comptry:55: can only be called from completion function
_tags:comptags:60: can only be called from completion function
_tags:comptags:67: can only be called from completion function

I am using scalacli version 1.0.0-RC2.

Jasper-M avatar May 15 '23 08:05 Jasper-M

I hacked the completions file into

#compdef _scala-cli scala-cli

function _scala-cli {
  eval "$(scala-cli complete zsh-v1 $CURRENT $words[@] | sed  's|\\||g')"
}

Now completions seem to work, but I probably don't get the intended quotes in the output...

export                              -- The export sub-command is experimental.

EDIT: this hack seems to completely break completions on scala-cli - or scala-cli --.

Jasper-M avatar May 15 '23 08:05 Jasper-M