nvim-java icon indicating copy to clipboard operation
nvim-java copied to clipboard

feature: java.action.generateAccessorsPrompt to pick only the field to generate getters and setters

Open SinbadTheSailor2005 opened this issue 11 months ago • 3 comments

Did you check the docs?

  • [x] I have read all the docs

Is your feature request related to a problem? Please describe.

In spring it is a common situation to create setters&getters for all fields. So make it automatically will significantly increase productivity.

Describe the solution you'd like

Just a pop up list of fields for implementing setters&getters

Describe alternatives you've considered

i have no alternative solutions, except manually write setters and getters

Additional context

No response

SinbadTheSailor2005 avatar Feb 15 '25 11:02 SinbadTheSailor2005

Not sure if I'm understanding correctly but can't you use Lombok for this? @Getter and @Setter works for me after adding lombok (both compileOnly and annotationProcessor) to Gradle.

YSNBx avatar Feb 16 '25 00:02 YSNBx

@YSNBx Wow! Never used lombok, but it seems it solved my problem. Big thanks!

SinbadTheSailor2005 avatar Feb 16 '25 06:02 SinbadTheSailor2005

@SinbadTheSailor2005 You can generate getters and setters for all the fields but picking only some fields are not yet supported.

You can use quick actions to generate getters setters. Here is the lua command you should execute to get the quick actions vim.lsp.buf.code_action().

If you want to have individual keymaps then look into this wiki https://github.com/nvim-java/nvim-java/wiki/Tips-&-Tricks#-running-code-actions

Of course lombok is also supported with this plugin

s1n7ax avatar Feb 16 '25 10:02 s1n7ax