marlonrichert / zsh-autocomplete

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
MIT License
5.26k stars 145 forks source link

Change the order of the completion, e.g. based on the extension or size of the entry #641

Closed tobiasBora closed 1 year ago

tobiasBora commented 1 year ago

What do you want?

Would it be possible to allow the user to change the order of the suggested completion, or even to move some item in a "less important" section? E.g. in:

image

I’d prefer to have:

  1. all .tex files appear first, before the .pdf (these are the "important extensions" I care about)
  2. the .bbl, .run.xml, .aux, .synctex.gz… appear in another section "less important files" rather than "files" since I never directly manipulate them and they pollute my view
  3. The "less important files" should also be determined by regexp, so that I can add for instance all files that contain "-pratend".
  4. if two files share the same base name like hey.tex and hey-backup.tex or hey-pratend-foo.tex, I would prefer to have the shorter files listed first: sometimes, I can even type the full name, and the file is listed at the very end of the line, making it hard to select:

image

(not that these screenshots are taken with a relatively old version (~1y) so things might have changed a bit now, but I see nothing in the doc about that anyway)

Why do you want this?

In LaTeX, you get an enormous amount of temporary files created during compilation, and most of the time only the .tex file and the .pdf files are important. Sometimes, some .tex files are also created with the same prefix but with an additional part in the name (the -pratend in the screenshot). This means that completion of these kind of files is very hard, and it is often easier to type the full name manually.

Who else would benefit from this?

People that care about some extensions more than others, so at least any LaTeX user.

How should it work?

The user should provide in configuration something like:

# first method (advanced users)
zsh_sort_function() { write the function that sets the category of each file and their position (for advanced users only)}
# second method (regular users)
- importantFiles: [ "\.tex$", "\.pdf$" ] # this will list tex before pdf
- lessImportantFiles: [ "\.bbl$", "\.synctex$", "-pratend-" ]
- priorityShortFiles: true

When I perform the following steps:

  1. Type a string with proposed completion

Then I expect the following to happen: