Ibrahim Abdelkareem
Ibrahim Abdelkareem

Reputation: 957

Zsh completion with fzf-tab doesn't work with dotnet command

I enabled zsh completion and added fzf-tab via zinit. It works as expected. I added some custom/extra completions e.g., aws cli and it also worked as expected.

However, when I tried to enable the completion for dotnet as recommended it didn't work with fzf. Please see the screenshots below and the code from my .zshrc for the completions.

What am I missing to get dotnet cli work with fzf-tab completion menu?

[![autoload bashcompinit; bashcompinit
autoload -Uz compinit; compinit

_comp_options+=(globdots) # With hidden files
_dotnet_zsh_complete()
{

local completions=("$(dotnet complete "$words")")
reply=( "${(ps:\n:)completions}" )

}

compctl -K _dotnet_zsh_complete dotnet
complete -C "/usr/local/bin/aws_completer" aws][1]][1]

This is how it looks with system commands e.g., cp when I press TAB enter image description here

This is how it looks with AWS CLI when I press TAB AWS completion

This is how it looks with dotnet CLI when I press TAB enter image description here

Upvotes: 2

Views: 927

Answers (1)

ArcherBird
ArcherBird

Reputation: 2134

You are trying to use the old compctl way, which does not work with fzf-tab.

Replace your config in .zshrc with this:

# zsh parameter completion for the dotnet CLI

_dotnet_zsh_complete()
{
  local completions=("$(dotnet complete "$words")")

  # If the completion list is empty, just continue with filename selection
  if [ -z "$completions" ]
  then
    _arguments '*::arguments: _normal'
    return
  fi

  # This is not a variable assignment, don't remove spaces!
  _values = "${(ps:\n:)completions}"
}

compdef _dotnet_zsh_complete dotnet

source: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete

Upvotes: 0

Related Questions