ms-jpq / coq_nvim

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.
GNU General Public License v3.0
3.56k stars 101 forks source link

Feature Idea: Inline suggestion using virtual text like fish shell #32

Closed IndianBoy42 closed 3 years ago

IndianBoy42 commented 3 years ago

An example from the fish shell website image

Fish shell implements a kind of 'inline' suggestions, wherein the first completion is showed as dull text after the cursor, the user can hit to get that completion, and then hit it again to get the full list.

I think something similar to the first part could be implemented using virtual text from neovim. Plus some configuration and keymaps to choose when to expand the full completion list, when to accept the first suggestion, when to cycle completion in virtual without opening the completion list, etc

The current completion popup window works fine, and should be the default for parity with other IDE, but this behaviour could be a more sleek and less visually disruptive way of presenting autocompletions for some people

(I also asked about this idea to compe but it hasn't been implemented yet)

YodaEmbedding commented 3 years ago

How I imagine this working:

Virtual text shows up. Press a hotkey (e.g. <C-h>) to accept it.

Questions:

  1. Should the completion popup also show? Or perhaps now that virtual text exists, the user may trigger it on demand.
  2. How should fuzzy completion be handled? Or does this only apply in fish-like guaranteed prefixes?
  3. What should it do if there is already text on the right? Should it be displaced? Should we instead redraw the line so that the virtual text is on top of the regular text (example)? What about syntax highlighting? What about line wrapping?
IndianBoy42 commented 3 years ago

How I imagine this working:

1.Virtual text shows up

  1. if acceptable press a hotkey and accept it
  2. if not then keep typing or call another hotkey to get the full popup menu

Answers

  1. I think it can be configurable, but making the popup only show up on demand probably makes sense
  2. I think fuzzy completion shouldn't happen so we only render virtual text to the right of where the user is typing (fuzzy results can be requested by activating the popup menu).
    • I think Fuzzy results being shown inline would result in the users cursors jumping around a lot, and some confusion on what is typed and what is virtual text
  3. Displaced text would be better in terms of being able to see the existing code, but would mean it would jump around a lot while typing. Letting the virtual just cover anything to the right would be more stable (we might need a way to temporarily disable the inline completions if the user wants to read the later code while in the middle of a word
ms-jpq commented 3 years ago

this is a super cool idea, I am not sure how this might work say if we already have some virtual text or something, but I will see what can be done.

To be clear, this is like a lower priority feature that will come after user defined snippets and such.

ms-jpq commented 3 years ago

the ghost text is here :)

I lied about this coming after user defined snippet.

https://user-images.githubusercontent.com/50598611/131977320-0d22d7f4-bda0-4e55-8784-770e7df410e2.mov

ms-jpq commented 3 years ago

coq_settings.display.ghost_text

The virtual text previewing selected completion

coq_settings.display.ghost_text.enabled

default:

True
coq_settings.display.ghost_text.context

Surrounding decoration around ghost text

[" 〈 ", " 〉"]
coq_settings.display.ghost_text.highlight_group

Ghost text colours

Comment
IndianBoy42 commented 3 years ago

What about making the ghosttext render over the text that would be replaced, rather than just to the right of the cursor? Also is it possible to have the pum not show up by default, but be brought up by a keypress?

ms-jpq commented 3 years ago

honestly? cuz it was in your screenshot l0l

ms-jpq commented 3 years ago

i suppose i could revisit this some time, but it will be after custom snippets

GBeauregard commented 3 years ago

I would love the ghost text rendering over the replaced text! A lot clearer.