Skip to content
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

Improve completion descriptions #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adelin-b
Copy link

@adelin-b adelin-b commented Oct 24, 2020

Following #127

This add an hook to be able to enrich the description of completion
Icons
image
image
Git status
image

What is left to do

  • How to set custom color ? it seem that if set in $__dscr they get escaped no matter what
    So I can do something like
    image
    instead of
    image
  • How to get the start input, git checkout <TAB> and have the string git checkout somewhere
    this is to match against a custom snippets file and would work a bit like bit https://github.com/chriswalz/bit but with all completion (like a real ide snippet !)
    image

@adelin-b adelin-b changed the title fix: realpath using word instead of description Improve completion descriptions Oct 24, 2020
@Aloxaf
Copy link
Owner

Aloxaf commented Oct 24, 2020

  1. This is difficult... You can reset the color, but you have no way to restore it.

  2. There is an array $words which contains the words on the command line. But it is editable so some completion function may remove some of its content...

@adelin-b
Copy link
Author

adelin-b commented Oct 28, 2020

  1. This is difficult... You can reset the color, but you have no way to restore it.

How can I do that ? it seems that the colors are getting escaped when I try to insert some inside the completion

fzf_tab_compadd_hook() {
  # $expl - explicit group name
  # $__hits - list of orginal completions
  # $__dscr - list of transformed and described completions
  # $PREFIX - text that already got completed before

  # (grep "\b$expl" ~/.config/clisnippets)

  case $_fzf_tab_curcontext in
    # All context
    (*)
    # Line by line icon assignements
    for i in {1..$#__hits}; do
      word=$__hits[i] dscr=$__dscr[i]
      if [[ -n $dscr ]]; then
        dscr=${dscr//$'\n'}
      elif [[ -n $word ]]; then
        dscr=$word
      fi
      case "$expl" in
              (*) icon="" ;;
      esac
      icon="$icon "
      RED='\033[0;31m'
      NC='\033[0m' # No Color
      __dscr[i]="${RED}$icon $dscr"
    done
    ;;
esac
}

image

@Aloxaf
Copy link
Owner

Aloxaf commented Oct 29, 2020

How can I do that ? it seems that the colors are getting escaped when I try to insert some inside the completion

You need to use $'\033[0m'

@adelin-b adelin-b force-pushed the improve_completion_description branch from e5fd6eb to 70536f0 Compare May 14, 2021 23:14
@adelin-b
Copy link
Author

Hello, I saw that this wasnt merged and Im still using the modified branch, I managed to do most of what I aimed for, beside color that did not work. However I found out you rewrote it all in C.

Here is what I have at the moment on https://github.com/adelin-b/fzf-tab/tree/improve_completion_description
Animation

It is on the old code so It might get me a while to move it to C. Maybe you already implemented the way to do it exposing different variable name?

@Aloxaf
Copy link
Owner

Aloxaf commented May 17, 2021

Oh sorry I haven't implement it in C. I will take a look at it in these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants