Skip to content

Conversation

@Suryansh-Dey
Copy link

@Suryansh-Dey Suryansh-Dey commented Mar 26, 2025

Problem

I had a visual problem in ghost text when using rust-tools, since it does pre-selects sometimes and sometimes not when no preferred completing item is available.
Now with current ghost text view, I can't know if it's the item is from the first item in the table or a pre-selected one:
Consider following images:

not pre-selected

not pre-selected

pre-selected

pre-selected

But the key difference is, in first instance, I need to select (Tab) then confirm (hit Enter) to get the ghost to real text while in second instance, I need hit enter stright up! Hitting Tab + Enter give wrong item!

To handle this, I need to keep checking the large completing menu to know if the ghost text item is pre-selected or not.
Hence ghost-text fails to achieve the actual moto i.e. accept completing without moving your eye off from the cursor.

Solution

I have made a slight change to allow to use different highlight group for not pre-selected ghost text (i.e. text due to first item in the menu) and pre-selected ghost text as you can see below

not pre-selected

image

pre-selected

image

Config used:

M.experimental = {
    ghost_text = {
        hl_group = 'Comment',
        hl_group_selected = "CmpItemAbbrMatch"
    }
}

Change

  • I just introduced one more option in M.experimental.ghost_text i.e. hl_group_selected (can be nil for backward compatibility) that applies on ghost-text when item is selected in completion menu.
  • If hl_group_selected is not used or nil, everything works as it used to do before.

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.

1 participant