elvish icon indicating copy to clipboard operation
elvish copied to clipboard

Add API for inserting autosuggestion

Open notramo opened this issue 7 years ago • 9 comments

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) (output_file)

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

notramo avatar Oct 31 '17 13:10 notramo

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

xiaq avatar Nov 08 '17 18:11 xiaq

  • It should support markup (underline, diminished, bold, italic).
  • It should be able to complete at more than one place: initial text: ~/code > kak ne/src/n/pa.cr autocompletion in more than one place: ~/code > kak neph/src/neph/parser.cr
  • The cursor mustn't be placed on this text, because it isn't real input.

notramo avatar Jan 19 '18 10:01 notramo

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

occivink avatar Jan 19 '18 11:01 occivink

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

On 19 Jan 2018 13:29, "Olivier Perret" [email protected] 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 .

adracea avatar Jan 19 '18 11:01 adracea

@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.

notramo avatar Jan 19 '18 12:01 notramo

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

occivink avatar Jan 19 '18 12:01 occivink

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?

xiaq avatar Jan 20 '18 16:01 xiaq

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 avatar Jan 21 '18 15:01 notramo

@xiaq, is there any progress on this?

notramo avatar May 23 '23 10:05 notramo