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

feat: able to change the ordering of popup menu #14006

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

kiddos
Copy link

@kiddos kiddos commented Feb 10, 2024

hi.

I was wondering if we can have a feature to change the ordering of the popup menu. The current popup menu is ordered as "word", "kind", "extra". I'm using an option to control this for now, not sure if there's a better way to accomplish this.

vim.mp4

@chrisbra
Copy link
Member

thanks, that sounds interesting. However I think the option value should not be an opaque integer value 012 but rather something like: :set pumordering=word,kind,extra

Hopefully that is flexible enough and others don't want printf() formatting strings (or add arbitrary items to the pum menu).

@chrisbra chrisbra added the needs more work used for a pull request that isn't ready to include (other than needing a test) label Feb 13, 2024
@kiddos
Copy link
Author

kiddos commented Feb 18, 2024

I see that some of the computation can be done at the option set callback, do I need to move the computation to the callback?

@chrisbra
Copy link
Member

I don't think so. The option callback is for completing option values. Does that work?

@chrisbra
Copy link
Member

can you please fix the failing CI?

@kiddos
Copy link
Author

kiddos commented Feb 25, 2024

I might need to add some tests too.

@chrisbra
Copy link
Member

yes, please add tests

@@ -6273,6 +6273,23 @@ A jump table for the options with a short description can be found at |Q_op|.
Insert mode completion. When zero as much space as available is used.
|ins-completion-menu|.

*'pumordering'* *'po'*
'pumordering' 'po' string (default "012")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be "word,kind,extra" ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

The default value:
0: word
1: kind
2: extra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, default value is no longer 0,1,2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea

src/popupmenu.c Outdated
for (r = 0; r < 3; ++r)
{
if (rounds[r] == 0 && prefix_pum_widths[rounds[r]] > 0)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove braces around single-line statements

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing

@chrisbra
Copy link
Member

can you add a few tests for:

  • set pumordering= (empty)
  • set pumordering=word,kind
  • set pumordering=word
  • set pumordering=extra
  • set pumordering=does-not-exists

@kiddos
Copy link
Author

kiddos commented Mar 11, 2024

I would say the current behavior for this case set pumordering=extra is kinda weird.

I could make it so that word, and kind would also appear?

let buf = RunVimInTerminal('-S Xscript', {})
call TermWait(buf)
call term_sendkeys(buf, "iaw\<C-X>\<C-u>")
call TermWait(buf, 50)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TermWait() is not needed before VerifyScreenDump()

So the popup menu should look like the following
"word" "kind" "extra"

If this value is set to 102, the popup menu would look like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still reference to 102

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooops

@chrisbra
Copy link
Member

I would say the current behavior for this case set pumordering=extra is kinda weird.

What do you mean with it?

I could make it so that word, and kind would also appear?

So that would basically mean, we would be able to re-order items, but cannot leave out items, right?

@kiddos
Copy link
Author

kiddos commented Mar 12, 2024

If user do this set pumordering=extra, only the extra will show up.
Yeah, I kind of want to make it so all items cannot be left out.

@chrisbra
Copy link
Member

If user do this set pumordering=extra, only the extra will show up.

Yes, it might be weird, and it sounds like a "don't complain if you use this setting and Vim does what you tell it. Don't do it then".

Not sure if this should be allowed to have only 'extra' in 'pumordering'. Opinions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more work used for a pull request that isn't ready to include (other than needing a test)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants