neogen icon indicating copy to clipboard operation
neogen copied to clipboard

Check if generation possible for current cursor position

Open mlthlschr opened this issue 2 years ago • 4 comments

Hi,

I am thinking about combining neogen with the lsp code actions. For that, I would like to check if it is possible to generate a comment at the current cursor position. If there is, I would like to display an option like "Generate comment" in the code action window.

I checked the API and it looks like right now it is only possible to trigger the generation, even if it is not at the cursor position. Is that correct?

Would be great if there was a way to check that. In case thats not available and not planned I offer help with implementation, if needed.

mlthlschr avatar Feb 28 '23 07:02 mlthlschr

You could use tree-sitter and simply detect all classes, functions, etc.

gshpychka avatar Aug 08 '23 12:08 gshpychka

If it is desired for the project or someone else is interested, I implemented a feature here triggering neogen for the node one line below. I am using it in combination with a keymap, so that a comment in the line above e.g. a function triggers neogen (comparable to the behavior in Jetbrains IDEs).

mlthlschr avatar Dec 24 '23 10:12 mlthlschr

Seems a very cool feature. However, I fall short understand what it needs to trigger neogen for the node one line below. If you are still interested in sharing, would you mind sharing a bit more ? And why not re-work the feature a bit, and create a PR for it ?

danymat avatar Aug 02 '24 14:08 danymat