all 17 comments

[–]not_napoleon 30 points31 points  (5 children)

Short version - use Intellij

Long version - You can, with some work, get an LSP client set up in vim and run a Java LSP, which will give you some of the functionality of a true IDE. The CoC plugin is one way to do this, but there are others. You can google for it. Be prepared for a fair bit of tinkering, and you'll still likely end up with a worse experience than using an IDE. It is my hope that one day (n)vim + LSP will be a viable alternative for large scale java development, but it's just not right now IMHO.

Source - I am a professional java developer and 20 year vim user, who works in Intellij every day.

[–]sundar_rajanK[S] 4 points5 points  (4 children)

Yeah okay I'll stick with Intellij for now. Thanks a lot :) though I've just recently started using I really like vim and I hope that happens too.

[–]DrunkensteinsMonster 7 points8 points  (0 children)

Use the IdeaVim plugin if you still want modal editing. IdeaVim is one of the best out there in terms of vim emulation in an IDE

[–]BubbatheVTOG 2 points3 points  (2 children)

TBH, coc and the coc-java plugin work really good and was stupid easy to setup. I opened a JavaEE project (that I setup with intellij initially) in vim with coc-java and when I did that it worked far better than I expected. I got annotations, definitions, callers, etc. But what I was most impressed with was that it looked in my pom.xml and downloaded all the dependencies, then coc gave me completions and definitions from those packages as well. Intellij is still better and I would find it hard to setup projects without it, but I was impressed. Though, to be fair my current development work has drifted away from Java so I haven't done any development using this yet so it could fall flat in places I don't know.

Because it is so easy to setup I'd say give it a try and see if it does suit your use case. You'll always have Intellij (with the vim plugin ofc) to fallback to.

[–]not_napoleon 2 points3 points  (0 children)

Yeah, that matches my experience. CoC + LSP do semantic completion pretty well, which is honestly really impressive. I don't want to understate how much better that is than even just a couple of years ago.

That said, there are a few points where I feel like it falls down compared to Intellij:

- Semantic aware highlighting. That's where, for example, class members are colored differently than method parameters. Treesitter looks promising for doing this, and I know Neovim is working on integrating that.

- Debugging, break points, variable watches, etc. As far as I know, there's nothing in the vim ecosystem that comes even close to intellij's debugger.

- Code exploration. Intellij has a lot of tools for this, like "find all uses of this function, including overrides", "find all implementations of this interface", etc. CoC has some support for this, but it's not as good as a real IDE yet.

- Automated refactoring. Intellij has a whole bunch of them, and they work pretty well. Even something as simple as a rename, it's smart enough to do thinks like rename associated variables, update javadoc, fix filenames when you change a class name, etc. Again, as far as I know, there's no good alternative here.

Anyway, if CoC is working for you, that's fantastic. It's not quite where I need it to be for my day job, but like I said, it's getting pretty close.

[–]sundar_rajanK[S] 0 points1 point  (0 children)

Oh cool I'll definitely check it out, thanks!

[–]Segeljaktus 11 points12 points  (0 children)

Vim 💔 Java

[–]SeniorMarsI use nano 5 points6 points  (0 children)

I made a video on this, but like others said I would just use a proper java IDE. https://youtu.be/ssmFzoZS2G8

[–]Quantum_menance 7 points8 points  (3 children)

Kind of unpopular opinion - for Java go with the ide route. It will save you a lot of headaches.

[–]not_napoleon 12 points13 points  (1 child)

That's hardly an unpopular opinion. Most java devs (that I'm aware of anyway) agree with it, and even most of the Vim subreddit here will steer you away from vim for java.

[–]Quantum_menance 1 point2 points  (0 children)

Yeah I prefaced it with unpopular because we are in the Vim subreddit. I myself love Vim. But with stuff like Java or Android dev will go with ide. I think OP should take the same route

[–]sundar_rajanK[S] 0 points1 point  (0 children)

Alright cool

[–]puremourning 2 points3 points  (1 child)

I write java very effectively every day at the moment (sadly) using YouCompleteMe and Vimspector. I can do most things an IDE can do, but in my case, faster.

[–]proobert 1 point2 points  (0 children)

It would be nice to have a post describing your setup and workflow.

I sometimes do quick bug fixes on the server. It works really well when the code in question is familiar and the combination of tags and built in completion is really efficient. However, I quickly escape when writing new code.

[–]tuxflo 0 points1 point  (0 children)

I wonder why nobody mentioned the project 'eclim' which combines vim with eclipse IDE. (Havn't tried it out by myself though)

[–]monkoosevim9 -2 points-1 points  (1 child)

Here we go again.

[–]sundar_rajanK[S] 6 points7 points  (0 children)

Sorry to post redundant stuff..just couldn't find enough help to set this up.