elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.62k stars 300 forks source link

Add API for inserting autosuggestion #507

Open notramo opened 6 years ago

notramo commented 6 years ago

This would look like the autosuggestion in fish. It would print some text after the current buffer of readline with diminished colouring, and readline wouldn't return this text. For example:

~/code > nvim /a/long/pa|th/to/a/file.txt

The cursor is at the | sign. The text after the cursor would be printed to the line with decreased intensity, but if the user hits return, only the following text would be returned: nvim a/long/pa. This would make possible implementing Elvishscript programmable autosuggestion in multiple ways: history only, or completion, or most often used command lines or files/directories, etc. Also, it would make easy to implement completion help:

~/code > ffmpeg| _(global_opts) (input_file_opts) (-i input_file) (output_file_opts) (outputfile)

and thousands of other things. This would make possible to solve #395, #396, #322 in Elvishscript.

xiaq commented 6 years ago

I changed the title. This sounds like a good way to implement autosuggestion.

notramo commented 6 years ago
occivink commented 6 years ago

autocompletion in more than one place sounds quite complex, can fish do it?

adracea commented 6 years ago

Does fish have to do it in order for elvish to do it ?

On 19 Jan 2018 13:29, "Olivier Perret" notifications@github.com wrote:

autocompletion in more than one place sounds quite complex, can fish do it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/elves/elvish/issues/507#issuecomment-358940353, or mute the thread https://github.com/notifications/unsubscribe-auth/AF7UBxDSpgBrXanmViBW3_C2GIBUHgrlks5tMHyEgaJpZM4QMwMz .

notramo commented 6 years ago

@occivink Elvish is not a fish copy, so the autocompletion shouldn't be a fish copy. I think these things are that make Elvish more powerful than other shells.

occivink commented 6 years ago

I never was implying this, I just wanted to know if fish did it and what kind of interface they might have

xiaq commented 6 years ago

Of course we want Elvish to be more powerful than other shells, everyone is on the same page :)

However, fish's autosuggestion works well because it only appends at the end of the input, which makes it non-intrusive: you can accept it when it is useful, but when it is not, it does not get in your way. But if we start inserting autosuggestions in arbitrary places, it can get distracting. @notramo, do you already have thoughts of how to make this work?

notramo commented 6 years ago

It would be used mostly for fuzzy completions: fuzzy path matching, or fuzzy history matching. Similar to fzf: it highlights matched text (this would be the real input in Elvish) and don't highlights the non-matched text (this would be the autosuggestion).

notramo commented 1 year ago

@xiaq, is there any progress on this?