Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if generation possible for current cursor position #132

Open
mlthlschr opened this issue Feb 28, 2023 · 4 comments
Open

Check if generation possible for current cursor position #132

mlthlschr opened this issue Feb 28, 2023 · 4 comments

Comments

@mlthlschr
Copy link

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.

@gshpychka
Copy link

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

@mlthlschr
Copy link
Author

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).

@danymat
Copy link
Owner

danymat commented Aug 2, 2024

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 ?

@ColinKennedy
Copy link
Contributor

ColinKennedy commented Sep 5, 2024

I would like to check if it is possible to generate a comment at the current cursor position

Generating under the current cursor is possible. In fact it's needed for #201

I added integration with LuaSnip + Neogen in a separate example: #202

Being able to generate docstring code at any cursor position I think would be a welcome thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants