Configure Neovim for Java Development

  Рет қаралды 10,856

Andrew Courter

Andrew Courter

Күн бұрын

In this video I go over how to configure Neovim for Java development using KickstartNvim, with nvim-jdtls and nvim-java (spoiler: I couldn't get this one to work for me). I also share my keymaps that you can use to organize imports and extract methods or extract variables.
Companion Article: levelup.gitconnected.com/conf...
My Neovim config: github.com/exosyphon/nvim
KickstartNvim: github.com/nvim-lua/kickstart...
java.lua config: github.com/exosyphon/nvim/blo...
Lombok issue: github.com/nvim-java/nvim-jav...
COC nvim for Java: • Setting up Neovim for ...
Install SDKMan: sdkman.io/
nvim-java: github.com/nvim-java/nvim-java
nvim-jdtls: github.com/mfussenegger/nvim-...
Join the channel to get access to perks:
www.youtube.com/@ascourter/join
Twitter: / exosyphon
Website: andrewcourter.com
Twitch: / exosyphon
Gear:
Mic: amzn.to/40GUGFg
Mic Interface: amzn.to/3YGxaGE
Mic preamp: amzn.to/3XtBXtY
Webcam: amzn.to/3OEOZRU
Boom Arm: amzn.to/3qLr0GE
Vissles (VS II switches): vissles.com/?ref=69zn8aei20 - Coupon Code for $5 off: ANDREWCOURTER
IQUNIX F97 (TTC ACE switches): iqunix.store/collections/f97-...
Free Stock Footage by videezy.com/
🎵 Music
Music : Way Home by Tokyo Music Walker
Stream & Download : fanlink.to/tmw_way_home
Creative Commons - Attribution 3.0 Unported - CC BY 3.0
⏰ Timestamps
0:00 Intro
1:22 Create example project
4:01 Install / Configure nvim-jdtls
8:21 Configure Lombok
12:34 Install / Configure nvim-java
14:54 Outro
#neovim #coding #java

Пікірлер: 97
@ascourter
@ascourter 3 ай бұрын
I will update here once I get nvim-java working and what the fix was.
@farzadmf
@farzadmf 3 ай бұрын
I suggest to maybe post a follow-up video when that happens
@ascourter
@ascourter 2 ай бұрын
@@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 2 ай бұрын
​@@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 2 ай бұрын
@@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 2 ай бұрын
@@ascourter No problem, sounds good!
@jackedkarlmarx
@jackedkarlmarx 2 ай бұрын
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 2 ай бұрын
If you are using Google Java Format do: null_ls.builtins.formatting.google_java_format.with({ extra_args = {"-aosp"} })
@obszczymucha1337
@obszczymucha1337 2 ай бұрын
This is gold. Thank you!
@CodingWithAuryn
@CodingWithAuryn Ай бұрын
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 Ай бұрын
Thanks for watching!
@jagernet
@jagernet 3 ай бұрын
I love Java and Neovim so this is so nice
@vikingthedude
@vikingthedude Ай бұрын
I don’t believe you
@joels1469
@joels1469 2 ай бұрын
Thank god I found this!!! THANK YOU
@antoninoadornetto6958
@antoninoadornetto6958 Ай бұрын
Great video! Thank you
@ivanmoya9115
@ivanmoya9115 2 ай бұрын
thanks, you really help fixed some issues.
@ascourter
@ascourter 2 ай бұрын
Glad it helped!
@ticler
@ticler 6 күн бұрын
Does it work with project that use mapstruct or metal model generators?
@ascourter
@ascourter 6 күн бұрын
Great question. I haven't tried a project with either of those yet
@NicolasRuizX
@NicolasRuizX 2 ай бұрын
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 2 ай бұрын
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 2 ай бұрын
@@ascourter Thanks, will do, because it's giving the error when injecting dependencies like this and using lombok it shouldn't happen
@NicolasRuizX
@NicolasRuizX 2 ай бұрын
@@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 2 ай бұрын
@@NicolasRuizX nice! I'm glad you got it working!
@guglielmobartelloni
@guglielmobartelloni 3 ай бұрын
did you try putting the "require" lines at the bottom of the kickstart config? For me it solved the issue
@ascourter
@ascourter 3 ай бұрын
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 3 ай бұрын
Ok, I placed them at the absolute end of the file but that didn't seem to work for me. :(
@guglielmobartelloni
@guglielmobartelloni 2 ай бұрын
@@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 2 ай бұрын
Thanks@@guglielmobartelloni , I'll give this a try today
@ascourter
@ascourter 2 ай бұрын
@@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
@elliotalderson9517
@elliotalderson9517 2 ай бұрын
java-nvim works fine for me, i used it with gradle and maven
@AndreLuisOS
@AndreLuisOS 23 күн бұрын
The only thing I don't know is how to update the project after adding a new dependency. Would you know?
@elliotalderson9517
@elliotalderson9517 19 күн бұрын
@@AndreLuisOS i use gradle for this, i think you can do the same if you're using maven
@cody_codes_youtube
@cody_codes_youtube 3 ай бұрын
Yeah dude! How long you’ve been doing Java now? You seeing a lot of opportunity in the java space?
@ascourter
@ascourter 3 ай бұрын
I think there's always opportunity in the Java space 😁
@cody_codes_youtube
@cody_codes_youtube 3 ай бұрын
@@ascourter that’s been a true statement for many decades. Haha
@andreasmertz9677
@andreasmertz9677 2 ай бұрын
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 2 ай бұрын
You might open an issue with the plugin and see if they can give you some guidance. Sorry it isn't working!
@LuanLouzada
@LuanLouzada Ай бұрын
and how do you automatically rename a file when changing a class?
@ascourter
@ascourter Ай бұрын
I believe the LSP should handle this if you do an LSP rename (vim.lsp.buf.rename())
@dougcarneiro
@dougcarneiro Ай бұрын
Couldnt make jdtls recognize lombok. Followed the exact same steps from video but didnt work :/
@ascourter
@ascourter Ай бұрын
That's no good! Try opening an issue on GitHub and see if they can get you fixed
@dadinhoschannel4003
@dadinhoschannel4003 3 ай бұрын
Can you do it for c#?
@ascourter
@ascourter 3 ай бұрын
I will add this to my list!
@Rahim-444
@Rahim-444 2 ай бұрын
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 2 ай бұрын
Are you using your own config or LazyVim?
@Rahim-444
@Rahim-444 2 ай бұрын
@@ascourter my own config
@ascourter
@ascourter 2 ай бұрын
@@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 2 ай бұрын
@@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 2 ай бұрын
@@Rahim-444 if you remove it from your ensure_installed section then mason shouldn't auto install and you can uninstall it manually
@CaptainDouchie
@CaptainDouchie 3 ай бұрын
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 3 ай бұрын
Did you try getting the more manual approach working?
@depreza68
@depreza68 2 ай бұрын
hello! i'm new on nvim rabbit hole, can this be done with packer?
@ascourter
@ascourter 2 ай бұрын
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 2 ай бұрын
@@ascourter thx alot! been watching your videos for almost a half a week!
@elliotalderson9517
@elliotalderson9517 2 ай бұрын
packer is deprecated now, even the developer of packer uses lazy, lazy is just better
@mars_0008
@mars_0008 3 ай бұрын
how about one neovim vid for Java's more modern and growing alternative - Kotlin?
@ascourter
@ascourter 3 ай бұрын
Maybe something like this? kzbin.info/www/bejne/rGqXc2d4r6ijnrc
@mars_0008
@mars_0008 3 ай бұрын
@@ascourter dam my memory failed me. Thanks! I think I actually watched this. Is Flutter useable in Neovim? (Unlike Kotlin).
@ascourter
@ascourter 3 ай бұрын
@@mars_0008 no worries. Hmmm I'm not sure about Flutter, I'm not sure off the top of my head.
@KaiyuLee
@KaiyuLee Ай бұрын
I like your kitty title bar style, can you share your config bro?
@ascourter
@ascourter Ай бұрын
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 Ай бұрын
@@ascourter thanks 👍
@123RogerioFerreira
@123RogerioFerreira 2 ай бұрын
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 2 ай бұрын
This is a good call-out. I believe I updated these correctly for Kickstart but will double check. Thanks!
@medaliboulaamail6491
@medaliboulaamail6491 3 ай бұрын
the correct answer should have been sudo apt install intellij but cool vid
@ascourter
@ascourter 3 ай бұрын
Ha. It would be nice if they allowed an embedded Neovim someday
@medaliboulaamail6491
@medaliboulaamail6491 3 ай бұрын
@@ascourter it would be awesome if they open sourced there java plugin just like there rust plugin
@errolloldham9995
@errolloldham9995 Ай бұрын
Promo_SM 😬
@c1dk1n
@c1dk1n 3 ай бұрын
Step 1) Configure Neovim for Java Step 2) Cry, because Java still isn't fun, even in Neovim.
@elliotalderson9517
@elliotalderson9517 2 ай бұрын
java is fun in neovim xd
@c1dk1n
@c1dk1n 2 ай бұрын
@@elliotalderson9517 we all can't be masochistic
@elliotalderson9517
@elliotalderson9517 2 ай бұрын
@@c1dk1n being masochist is funny i suppose
@n3rd235
@n3rd235 Ай бұрын
dissapointing
@ascourter
@ascourter Ай бұрын
Yep, still trying to figure this one out 😞
@brianfarias7285
@brianfarias7285 2 ай бұрын
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 2 ай бұрын
Seems like the LSP is not connected or running. If you use :LspInfo do you see anything?
@brianfarias7285
@brianfarias7285 2 ай бұрын
@@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 2 ай бұрын
@@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 2 ай бұрын
@@brianfarias7285 yeah, see if you can figure out why you have two instead of one
@user-qs6js1zs9x
@user-qs6js1zs9x Ай бұрын
Did you fix that? I have the same problem, 1 client is running
Why oil.nvim is the best directory plugin
9:12
Andrew Courter
Рет қаралды 21 М.
The Best Oil.nvim Configuration
7:15
Andrew Courter
Рет қаралды 6 М.
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 12 МЛН
Кәріс өшін алды...| Synyptas 3 | 10 серия
24:51
kak budto
Рет қаралды 1,3 МЛН
I Love Neovim But I WONT Use It | Prime Reacts
23:22
ThePrimeTime
Рет қаралды 107 М.
AstroNvim - лучшая IDE на NeoVim для разработчика
32:54
PurpleSchool | Anton Larichev
Рет қаралды 66 М.
Neovim Starter Kit for Java
11:12
Nerd Signals
Рет қаралды 3,8 М.
Neovim Tutorial - Java + Lombok
8:16
Ivan Byte TV
Рет қаралды 22 М.
Java в NeoVim, nvim-jdtls
45:45
Куда войти?
Рет қаралды 3,4 М.
Why Neovim nerds are so obsessed with the terminal
6:44
Joshua Morony
Рет қаралды 75 М.
Why I think IDEs suck
2:58
typecraft
Рет қаралды 12 М.
Which is Better Flash.nvim OR Leap.nvim?
11:35
Andrew Courter
Рет қаралды 7 М.
How To Make Your Boring macOS Terminal Amazing With Alacritty
16:33
Josean Martinez
Рет қаралды 105 М.
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 5 МЛН
How To Unlock Your iphone With Your Voice
0:34
요루퐁 yorupong
Рет қаралды 22 МЛН
i love you subscriber ♥️ #iphone #iphonefold #shortvideo
0:14
МОЩНЕЕ ТВОЕГО ПК - iPad Pro M4 (feat. Brickspacer)
28:01
ЗЕ МАККЕРС
Рет қаралды 74 М.
📦Он вам не медведь! Обзор FlyingBear S1
18:26
Жёсткий тест чехла Spigen Classic C1
0:56
Romancev768
Рет қаралды 689 М.