supermaven-inc / supermaven-nvim

The official Neovim plugin for Supermaven
https://supermaven.com/
MIT License
279 stars 16 forks source link

Feature: accept line keymap #48

Open pedro757 opened 4 weeks ago

pedro757 commented 4 weeks ago

I want to accept line by line, not the whole suggestion.

AlejandroSuero commented 3 weeks ago

@pedro757 I made the changes on the PR above.

Test it out and tell me your thoughts on it.

sm-victorw commented 3 weeks ago

I believe the plugin typically only suggests a single line at a time, only giving multi-line suggestions when the suggestion starts with a newline character (ie the cursor is at the end of the current line). In this case, it was intended that you would be able to accept a single line by inserting a newline yourself (e.g. with return or enter) and since the suggestion no longer starts with a newline, accepting the completion would only insert a single line.

When you reference wanting to accept a single line, is this in the context of the cursor being at the end of the current line, and multiple lines are being displayed below?

AlejandroSuero commented 3 weeks ago

@sm-victorw the plugin does indeed only suggests the current line if inserting a new line, I think, and here I could be misspeaking, that the intention is to for example given the following suggestion:

-- user writes function test(opts) - [cursor at the end]
-- Supermaven suggests:
--   if opts ~= nil then
--     return opts
--   end - User only wants to accept until this line and then change the text to get another suggestion
--   return nil
-- end
AlejandroSuero commented 3 weeks ago

@sm-victorw That I discovered when implementing accept_line feature, but I think it will be better to create a new PR fixing that if that's not the intended behaviour.

As I said in #54, this happens on any form of accepting (accept_suggestion and accept_word) if a new line is inserted and the suggestion is indented.

AlejandroSuero commented 3 weeks ago

@sm-victorw I think that the solution that neocodium is doing (I just skimmed it when @chrisgrieser mentioned it), is to set the whole line in the buffer with the suggested text.