zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.45k stars 67 forks source link

Option to dismiss copilot when leaving insert mode #179

Closed RyanCarrier closed 1 year ago

RyanCarrier commented 1 year ago

Would be great to have an option to auto dismiss copilot's suggestion when leaving insert mode.

Sometimes it will leave artifacts as I'm moving around making it hard to see what's written/what's underneath. Going into and our of insert mode solves it, (or dismissing manually)

MunifTanjim commented 1 year ago

Would be great to have an option to auto dismiss copilot's suggestion when leaving insert mode.

It already does so.

https://github.com/zbirenbaum/copilot.lua/blob/77e3a4907928f0813024e573b882dc879dfc0c6b/lua/copilot/suggestion.lua#L486-L488

https://github.com/zbirenbaum/copilot.lua/blob/77e3a4907928f0813024e573b882dc879dfc0c6b/lua/copilot/suggestion.lua#L521-L525

Let me know if you can reproduce when it doesn't work.

RyanCarrier commented 1 year ago

https://github.com/zbirenbaum/copilot.lua/assets/9389452/60d94f83-0650-46ba-bf5f-3250f15c5f82

Only lazy and copilot installed in this example, up to date

MunifTanjim commented 1 year ago

What happens when you run :redraw the the virtual text stays back after leaving insert mode? Does it disappear?

RyanCarrier commented 1 year ago

Virtual text still stays after running :redraw

MunifTanjim commented 1 year ago

Just to make sure, is it still the same if you do :redraw! (notice the bang at the end, it redraws entire screen).

MunifTanjim commented 1 year ago

Also, do you use <C-c> to exit insert mode by any chance?

RyanCarrier commented 1 year ago

No change with :redraw! Yes I do use C-c....

MunifTanjim commented 1 year ago

<C-c> does not trigger the InsertLeave autocmd.

So you should: