Тёмный

Configure Neovim for Java Development 

Andrew Courter
Подписаться 8 тыс.
Просмотров 20 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 115   
@ascourter
@ascourter 6 месяцев назад
I will update here once I get nvim-java working and what the fix was.
@farzadmf
@farzadmf 6 месяцев назад
I suggest to maybe post a follow-up video when that happens
@ascourter
@ascourter 6 месяцев назад
@@JonathanMorrisMusic Oh good suggestion. Do you know offhand where the data directory is by default in nvim-java? I have been blowing away ~/.local/share/KickstartNvim but if it is outside that directory then this may be tripping me up.
@JonathanMorrisMusic
@JonathanMorrisMusic 6 месяцев назад
​@@ascourter I apparently must have been temporarily banned from posting on YT since I've been trying to reply to this message for the past day lol. Must be because I tried to post a bash command. Anyway, it's defined in the nvim-java/nvim-java-core plugin and resolves to either HOME/.cache/nvim/jdtls/workspaces/common-workspace or XDG_CACHE_HOME/nvim/jdtls/workspaces/common-workspace (removing the dollar signs from the variables in case I get flagged again somehow).
@ascourter
@ascourter 6 месяцев назад
@@JonathanMorrisMusic Oh geez, I was wondering what happened to your messages when I looked for them. Crazy that you got a temporary ban. Thank you for your perseverance in posting the comment! I will check this and see if removing that cache gets this working for me. Thanks!
@JonathanMorrisMusic
@JonathanMorrisMusic 6 месяцев назад
@@ascourter No problem, sounds good!
@johnr598
@johnr598 2 месяца назад
You're a better man than me man. I use vim and I used it for JS and TS but it's always been my dream to also use it with Java, but this seems too hardcore and error prone to me. Maybe one day..
@krige
@krige Месяц назад
0:56 could you elaborate on what you mean with "document symbols" and "language definitions"? A few missing features from your list are syntax highlighting, code navigation, code refactoring, formatting and debugging. Perhaps some of these are included in the two features I am asking about?
@ascourter
@ascourter Месяц назад
Good question. For Language Definitions I meant looking through language level APIs (e.g. if you went to definition on a library method, it would take you to the definition or interface). Document symbols is a term used by other plugins that allow you to view a file at a high level so I should have used a different term there. syntax highlighting should come from Treesitter. Code Navigation & Refactoring should come from the LSP (nvim-jdtls has specific commands you can call for refactoring). Debugging is missing and I was actually working on that capability today. But it is not coming together as easily as I had hoped.
@krige
@krige Месяц назад
3:12 Is treesitter automatically installed with kickstart?
@ascourter
@ascourter Месяц назад
Yes treesitter should be installed and then when it detects a Java file I believe it will install that grammar. Adding it into the config will make it explicit and install it before you land in a Java file.
@123RogerioFerreira
@123RogerioFerreira 5 месяцев назад
Maybe the issue is related to the paths used in your java.lua? Seems like you are using different share directories. Could you try changing '/.local/share/nvim' to '/.local/share/KickstartNvim'?
@ascourter
@ascourter 5 месяцев назад
This is a good call-out. I believe I updated these correctly for Kickstart but will double check. Thanks!
@andreasmertz9677
@andreasmertz9677 6 месяцев назад
Im able to install Lombok as a dependency and make Neovim recognise Lombok, however I can't seem to use my Getter method
@ascourter
@ascourter 6 месяцев назад
You might open an issue with the plugin and see if they can give you some guidance. Sorry it isn't working!
@CaptainDouchie
@CaptainDouchie 6 месяцев назад
i thought it was going to be the first up to date java config for neovim but it ended up not working too
@ascourter
@ascourter 6 месяцев назад
Did you try getting the more manual approach working?
@depreza68
@depreza68 6 месяцев назад
hello! i'm new on nvim rabbit hole, can this be done with packer?
@ascourter
@ascourter 6 месяцев назад
Welcome! Of course, replace lazy.nvim with packer and the installation should be the same. I would recommend migrating to lazy.nvim though since packer is no longer maintained.
@depreza68
@depreza68 6 месяцев назад
@@ascourter thx alot! been watching your videos for almost a half a week!
@elliotalderson9517
@elliotalderson9517 5 месяцев назад
packer is deprecated now, even the developer of packer uses lazy, lazy is just better
@brianfarias7285
@brianfarias7285 6 месяцев назад
Using gd does not take me to definitions I only get "[telescope.builtin.lsp_*]: server does not support definitionProvider" Also, autocomplete did not show "classUnderTest" Could somebody help?
@ascourter
@ascourter 6 месяцев назад
Seems like the LSP is not connected or running. If you use :LspInfo do you see anything?
@brianfarias7285
@brianfarias7285 6 месяцев назад
@@ascourter It seems like at some point i messed up compl Here's the response i get from :LspInfo: Language client log: /home/brianvf/.local/state/nvim/lsp.log Detected filetype: java 2 client(s) attached to this buffer: Client: jdtls (id: 1, bufnr: [8]) filetypes: autostart: false root directory: /home/brianvf/coding/java cmd: /home/brianvf/.local/share/nvim/mason/bin/jdtls Client: jdtls (id: 2, bufnr: [8]) filetypes: java autostart: true root directory: /home/brianvf/coding/java cmd: /home/brianvf/.local/share/nvim/mason/bin/jdtls -configuration /home/brianvf/.cache/jdtls/config -data /home/brianvf/.cache/jdtls/workspace Configured servers list: jdtls, lua_ls, tsserver
@brianfarias7285
@brianfarias7285 6 месяцев назад
@@ascourter It shows me the following 2 client(s) attached to this buffer: Then I have jdtls twice. Guess I mesed up somehow
@ascourter
@ascourter 6 месяцев назад
@@brianfarias7285 yeah, see if you can figure out why you have two instead of one
@NobodyLast-r4u
@NobodyLast-r4u 5 месяцев назад
Did you fix that? I have the same problem, 1 client is running
@CodingWithAuryn
@CodingWithAuryn 4 месяца назад
Awesome video and overview, thank you :) Til now I used for Java intellij, but I prefer nvim so much So will switch also for Java now
@ascourter
@ascourter 4 месяца назад
Thanks for watching!
@jackedkarlmarx
@jackedkarlmarx 6 месяцев назад
I had my java config already working, however it kept using 2 space indents because of format being enabled, thank you for this tutorial very helpful!
@hyltoncarboo8303
@hyltoncarboo8303 6 месяцев назад
If you are using Google Java Format do: null_ls.builtins.formatting.google_java_format.with({ extra_args = {"-aosp"} })
@dougcarneiro
@dougcarneiro 4 месяца назад
Couldnt make jdtls recognize lombok. Followed the exact same steps from video but didnt work :/
@ascourter
@ascourter 4 месяца назад
That's no good! Try opening an issue on GitHub and see if they can get you fixed
@sefumies
@sefumies 6 дней назад
Same here, in fact, the jdtls configuration appears to be incorrect also.
@cody_codes_youtube
@cody_codes_youtube 6 месяцев назад
Yeah dude! How long you’ve been doing Java now? You seeing a lot of opportunity in the java space?
@ascourter
@ascourter 6 месяцев назад
I think there's always opportunity in the Java space 😁
@cody_codes_youtube
@cody_codes_youtube 6 месяцев назад
@@ascourter that’s been a true statement for many decades. Haha
@ticler
@ticler 3 месяца назад
Does it work with project that use mapstruct or metal model generators?
@ascourter
@ascourter 3 месяца назад
Great question. I haven't tried a project with either of those yet
@dadinhoschannel4003
@dadinhoschannel4003 6 месяцев назад
Can you do it for c#?
@ascourter
@ascourter 6 месяцев назад
I will add this to my list!
@sefumies
@sefumies 6 дней назад
Nice, but now seems dated and now no longer works, the configuration is incorrect
@ascourter
@ascourter 6 дней назад
Oh no! What error are you getting? Hopefully that hatred is not directed at me
@sefumies
@sefumies 4 дня назад
@@ascourter Expected a table of specs but a nil was returned (from the jdtls code) I have a large Neovim setup with lazy and all my plugins are in individual Lua files, the jdtls plugin is the only one which fails. Health check is fine, as is Java (I do a lot of Spring / Java development) it seems to be a syntax issue. (Copied mainly from the repos)
@keaneplayingmbae2852
@keaneplayingmbae2852 28 дней назад
☕ for those are setting this up for OOP in C.S or for Springboot for a java development
@jagernet
@jagernet 6 месяцев назад
I love Java and Neovim so this is so nice
@vikingthedude
@vikingthedude 5 месяцев назад
I don’t believe you
@mars_0008
@mars_0008 6 месяцев назад
how about one neovim vid for Java's more modern and growing alternative - Kotlin?
@ascourter
@ascourter 6 месяцев назад
Maybe something like this? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-v94B4BzCphU.html
@mars_0008
@mars_0008 6 месяцев назад
@@ascourter dam my memory failed me. Thanks! I think I actually watched this. Is Flutter useable in Neovim? (Unlike Kotlin).
@ascourter
@ascourter 6 месяцев назад
@@mars_0008 no worries. Hmmm I'm not sure about Flutter, I'm not sure off the top of my head.
@medaliboulaamail6491
@medaliboulaamail6491 6 месяцев назад
the correct answer should have been sudo apt install intellij but cool vid
@ascourter
@ascourter 6 месяцев назад
Ha. It would be nice if they allowed an embedded Neovim someday
@medaliboulaamail6491
@medaliboulaamail6491 6 месяцев назад
@@ascourter it would be awesome if they open sourced there java plugin just like there rust plugin
@elliotalderson9517
@elliotalderson9517 5 месяцев назад
java-nvim works fine for me, i used it with gradle and maven
@AndreLuisOS
@AndreLuisOS 4 месяца назад
The only thing I don't know is how to update the project after adding a new dependency. Would you know?
@elliotalderson9517
@elliotalderson9517 4 месяца назад
@@AndreLuisOS i use gradle for this, i think you can do the same if you're using maven
@artembaranov8456
@artembaranov8456 3 месяца назад
Bro, do ya know can a neovim run java code?
@ascourter
@ascourter 3 месяца назад
Are you asking if you can develop Java in Neovim?
@LorenzoBettini
@LorenzoBettini 2 месяца назад
You haven't made the follow-up video for Java debugging and testing, have you? Thanks for the video btw
@ascourter
@ascourter 2 месяца назад
@@LorenzoBettini I haven't made the follow up yet. I'll put it on my list next to see if I can get it working
@VANTYCSolutions
@VANTYCSolutions 2 месяца назад
The best NeoVim Java setup. Thankyou!
@Pedro-qj9mn
@Pedro-qj9mn 3 месяца назад
My go to definition don't works
@ascourter
@ascourter 3 месяца назад
Hmmm, double check your LSP is configured correctly by running :LspInfo.
@joels1469
@joels1469 5 месяцев назад
Thank god I found this!!! THANK YOU
@Luanxxxxx
@Luanxxxxx 4 месяца назад
and how do you automatically rename a file when changing a class?
@ascourter
@ascourter 4 месяца назад
I believe the LSP should handle this if you do an LSP rename (vim.lsp.buf.rename())
@byt3blitz
@byt3blitz 5 месяцев назад
Great video! Thank you
@errolloldham9995
@errolloldham9995 5 месяцев назад
Promo_SM 😬
@NicolasRuizX
@NicolasRuizX 6 месяцев назад
Hello, I'm using java 21 with springboot and I did exactly what you show for jdtls, and I get the error of "The blank final field may not have been initialized", where Intellij doesn't give me this error. Do you know something about it?
@ascourter
@ascourter 6 месяцев назад
I haven't seen that one before. You might check this out: stackoverflow.com/questions/28129169/the-blank-final-field-may-not-have-been-initialized If that doesn't help then I'd open an issue on jdtls and see if someone there can help
@NicolasRuizX
@NicolasRuizX 6 месяцев назад
@@ascourter Thanks, will do, because it's giving the error when injecting dependencies like this and using lombok it shouldn't happen
@NicolasRuizX
@NicolasRuizX 6 месяцев назад
@@ascourter I tried nvim-java and worked like a charm, I didn't get any issues and I did exactly as you did. Thank you very much, good content :D
@ascourter
@ascourter 6 месяцев назад
@@NicolasRuizX nice! I'm glad you got it working!
@ivanmoya9115
@ivanmoya9115 5 месяцев назад
thanks, you really help fixed some issues.
@ascourter
@ascourter 5 месяцев назад
Glad it helped!
@Rahim-444
@Rahim-444 6 месяцев назад
i still have a problem with having two lsp instances running at the same time one belongs mason and the other is from the lsp installed with lazy
@ascourter
@ascourter 6 месяцев назад
Are you using your own config or LazyVim?
@Rahim-444
@Rahim-444 6 месяцев назад
@@ascourter my own config
@ascourter
@ascourter 6 месяцев назад
@@Rahim-444 is it two jdtls instances? You should only have one running so you'll have to drop one so you don't have collisions
@Rahim-444
@Rahim-444 6 месяцев назад
@@ascourter how can i drop the mason one ? it has auto start on, the other one is the plugin one both are running at the same time
@ascourter
@ascourter 6 месяцев назад
@@Rahim-444 if you remove it from your ensure_installed section then mason shouldn't auto install and you can uninstall it manually
@KaiyuLee
@KaiyuLee 5 месяцев назад
I like your kitty title bar style, can you share your config bro?
@ascourter
@ascourter 5 месяцев назад
Here's my config that has my kitty conf file. The status bar you're talking about is from tmux. That config is under the tmux conf file. I went over setting up tmux in a previous video if that helps. github.com/exosyphon/dotfiles
@KaiyuLee
@KaiyuLee 5 месяцев назад
@@ascourter thanks 👍
@obszczymucha1337
@obszczymucha1337 6 месяцев назад
This is gold. Thank you!
@guglielmobartelloni
@guglielmobartelloni 6 месяцев назад
did you try putting the "require" lines at the bottom of the kickstart config? For me it solved the issue
@ascourter
@ascourter 6 месяцев назад
I put them right above the mason-lspconfig line, I'll try putting them at the very end and see if that gets it working. Thanks!
@ascourter
@ascourter 6 месяцев назад
Ok, I placed them at the absolute end of the file but that didn't seem to work for me. :(
@guglielmobartelloni
@guglielmobartelloni 6 месяцев назад
@@ascourter tldr: put the require('java').setup() in the config function of nvim-java, put the require('lspconfig').jdtls.setup {} at the very bottom of the file. Edit: I posted a comment with a github link but I think it was filtered out
@ascourter
@ascourter 6 месяцев назад
Thanks@@guglielmobartelloni , I'll give this a try today
@ascourter
@ascourter 6 месяцев назад
@@guglielmobartelloniI updated my config but it still won't work for me. I am getting a different error. Here's the open issue I have on Github: github.com/nvim-java/nvim-java/issues/135
@n3rd235
@n3rd235 5 месяцев назад
dissapointing
@ascourter
@ascourter 5 месяцев назад
Yep, still trying to figure this one out 😞
@c1dk1n
@c1dk1n 6 месяцев назад
Step 1) Configure Neovim for Java Step 2) Cry, because Java still isn't fun, even in Neovim.
@elliotalderson9517
@elliotalderson9517 5 месяцев назад
java is fun in neovim xd
@c1dk1n
@c1dk1n 5 месяцев назад
@@elliotalderson9517 we all can't be masochistic
@elliotalderson9517
@elliotalderson9517 5 месяцев назад
@@c1dk1n being masochist is funny i suppose
Далее
Intro to Customizing LazyVim
8:10
Просмотров 16 тыс.
My Neovim configuration in 2024
20:48
Просмотров 8 тыс.
CORTE DE CABELO RADICAL
00:59
Просмотров 2,2 млн
We finally APPROVED @ZachChoi
00:31
Просмотров 9 млн
ТАРАКАН
00:38
Просмотров 727 тыс.
Как быстро освоить Vim / Neovim?
23:31
I Love Neovim But I WONT Use It | Prime Reacts
23:22
Просмотров 121 тыс.
Why Neovim nerds are so obsessed with the terminal
6:44
Why I Cant Stand IDE's After Using VIM | Prime Reacts
17:51
NeoVim - лучший редактор кода
12:32
Просмотров 191 тыс.
30 Vim commands you NEED TO KNOW (in just 10 minutes)
10:27
CORTE DE CABELO RADICAL
00:59
Просмотров 2,2 млн