supermaven-inc / supermaven-nvim

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

Allow to disable supermaven using comments. #100

Open Shobhit0109 opened 4 days ago

Shobhit0109 commented 4 days ago

Like we have eslint to disable rule checking , allow supermaven to disable autocomplete in a specific part of code.

eg. It will not show suggestions in from line: // disable supermaven upto line: // enable supermaven

AlejandroSuero commented 2 days ago

There are 3 options to implement this that comes to my mind:

The first two will need to parse the comment value to check that the value its correct. Then detect if the cursor is between both comments and don't provide suggestions.

[!warning] Unless implemented with sm-agent behaviour it will still send the code to be analyzed but will disable the suggestion display behaviour.

If what you want is to not send the code, the best solution will be to wait for the raise of implementation on the agent. Otherwise create a new logic to pause the agent running within the plugin but still listen to document listeners to resume after going out of the comment bounds, but when it resumes it will send the file to get suggestions still.

Shobhit0109 commented 2 days ago

I think, we should disable suggestions for a complex logic rather than the extension itself as extension will learn from the code. Therefore, what I suggest is using any of the first 2 mentioned. We can use another comments type for private code which can be implemented in sm-agent. Currently no other ai agent is giving this feature, so this can increase trust and productivity.

AlejandroSuero commented 2 days ago

I think I could be possible, would be a good size PR so if @sm-victorw or @super-jacob has something to say about it, to do it or not really. I can maybe start doing it if someone doesn't start it by after the next week.

But as you said I think the first 2 implementations would be the best. Not sure if we can do something like instead of sending the whole buffer, send it but stripped of the sections between comments so it doesn't send that data. But this is something that I don't have a say on that.

Would be nice to be the first AI code copilot to do something like that so ensures more trust and productivity to the users. As they are developing their own editor, it would be a nice feature to implement there if done at plugin level.

[!note] One small design aspect I would like to tackle would be the change on how to do the parsing.

i.e.

-- supermaven: disable
local lua_code = "test_code"
-- supermaven: enable

The syntax of supermaven: <action> I think would be a better way to parse in case you are disabling other linters or formatters that use enable <program> so if it finds supermaven: then checks the action, otherwise would skip that part of the logic.