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: Patch sorting popup autocomplete items and initial builtin items #2518

Merged
merged 5 commits into from
May 24, 2023

Conversation

03juan
Copy link
Contributor

@03juan 03juan commented May 22, 2023

Description

I noticed that neovim wasn't sorting the list of autocomplete items when pressing tab in the command line.

In my very limited lua + nvim knowledge, there doesn't seem to be a way to create an autocommand that intercepts the completion list in the command popup.

So I decided to try my hand at brute-forcing the solution from telescope's side.

Here I sort the list of available commands for each of the 4 possible code paths.

The initial builtin list is also unsorted.

Let me know if this is useful or if you have any other recommendations for sorting the options. It's also ok if this feature is not wanted. 👍

(I messed up and renamed the branch on the closed PR #2515 not knowing GH would close it. Sorry for the double submission)

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • Various print commands to ensure I hit all 4 paths.
    image

  • Testing the autocompletions manually and ensuring no errors or unexpected suggestions.

  • n == 0
    image

  • :Telescope <Tab>

    • Before:
      image
    • After:
      image
  • :Telescope l<Tab>

    • Before:
      image
    • After:
      image
  • n == 1 and #is_extension > 0
    image

  • :Telescope gh <Tab>

    • Before:
      image
    • After:
      image
  • n == 1 and #is_extension == 0
    image

  • :Telescope autocommands <Tab>

    • Before:
      image
    • After:
      image
  • n > 1
    image

  • :Telescope autocommands wrap_results <Tab>

    • Before:
      image
    • After:
      image
  • :Telescope gh issues <Tab>

    • Before:
      image
    • After:
      image
  • Builtin list
    Left: Before
    Right: After
    image

All tests pass on the fork ✅

Configuration:

  • Neovim version (nvim --version): 0.9.0
  • Operating system and version: Ubuntu 22.04 in WSL2 on Windows 11

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

03juan and others added 2 commits May 21, 2023 15:08
I noticed that neovim wasn't sorting the list of autocomplete items when pressing tab in the command line, e.g. `:Telescope <Tab>`.

In my very limited lua + nvim knowledge, there doesn't seem to be a way to create an autocommand that intercepts the completion list in the command popup.

So I decided to try my hand at brute-forcing the solution from telescope's side.

Here I sort the list of available commands for each of the 3 possible code paths.

Let me know if this is useful or if you have any other recommendations for sorting the options. It's also ok if this feature is not wanted. 👍
@03juan 03juan changed the title Patch sorting feat: Patch sorting popup autocomplete items and initial builtin items May 22, 2023
@Conni2461
Copy link
Member

thanks :) i just merged another branch into master and it looks like you need to rebase/merged master in again, sorry.

If you want i could resolve it

@03juan
Copy link
Contributor Author

03juan commented May 24, 2023

Yes please, I'm not that great with git. Go ahead and rebase/squash as you see fit :)

@Conni2461 Conni2461 merged commit 8dd1cb2 into nvim-telescope:master May 24, 2023
@Conni2461
Copy link
Member

thanks :)

@03juan
Copy link
Contributor Author

03juan commented May 24, 2023

I'll be sure to format with stylua locally before pushing in the future!

Conni2461 pushed a commit that referenced this pull request May 24, 2023
abelmul pushed a commit to abelmul/telescope.nvim that referenced this pull request Jun 6, 2023
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