12 ms·
So you want to write Java in Neovim
- tpoacher 2y agoI unironically use nano for this (albeit with lots of custom macros). It just works. (though obviously jshell kicks in quite a bit during coding sessions, and on top of that I have several templates and custom shell scripts that help navigate docs easily)
- pyrale 2y agoThere are more and more successful experiments with nvim and java recently. Considering the amount of black magic happens in idea, and seeing how it fails sometimes, it’s probably tome for me to try migrating again.
- dotancohen 2y agoI love the allusion to HTML Goodies in the title. I haven't seen that style for maybe two decades, it even took me a minute to remember the name of the site.
- jhardy54 2y agoDo you mean the “so you want to ____” format? If so, I don’t think it’s an allusion to HTML Goodies — it’s a decently popular meme that goes back at least the early 80’s (e.g. “So You Want To Be A Wizard”).
- przmk 2y agoLooks very nice. One thing that always prevents me from using anything other than a full-blown IDE for Java is the fact that most entreprise projects use Maven and structure packages with the default Java way by using the FQDN structure (e.g.: org/example/groupid/packageid/submodule/File.java). Maybe I'm missing something but navigating and finding/adding files in a structure that's 10-20 directories deep or more seems like a nightmare in pure Vim.
- qup 2y agoyou want the ctrl+p plugin It's a fuzzy file finder. For your example of `org/example/groupid/packageid/submodule/File.java` I might write "[Ctrl+P] pamodFi[Enter]" If `File.java` is unique enough, I can just type that and it finds it without issue. There's also filetree plugins if you really want the visual clutter
- wffurr 2y agoA good fuzzy finder helps a lot with this. You can type something like `ccufFoo` to match `com.company.util.factories.FooWidgetFactory`. I use fzf.vim for this. Thankfully my company has its own hosted LSP that supports Java (and every other language in our bazel monorepo) so I don’t have to mess around with Eclipse and JDTLS (what happened to eclim?). But at a prior company I just worked without an LSP and just did a lot of referencing Java docs in a browser and split screen files.
- deleted 2y ago[deleted]
- chessweb73 2y ago[flagged]
- alexvitkov 2y agoThis is not an unpopular opinion you needed to make a new account for. None of us do.
- gilleain 2y agoAgreed. With some decades of Java experience, I would only use Eclipse or IntelliJ or similar to develop non-trivial Java programs.
- aomix 2y agoEven the post is in terms if "Dear god why? But if you must..."
- haltcatchfire 2y agoI tried to give it a shot this year. Autocomplete (and especially Co-pilot) works really well nowadays. What made me reconsider is actually how imports are sorted and organised - they differ from how IntelliJ does it, which all other developers in my team uses. It’s a tiny but nagging issue for which I haven’t found a solution. It doesn’t help that IntelliJ is spectacularly good out of the box hah…
- soraminazuki 2y agoI always choose standalone tools for formatting so that it can be integrated into any editor/IDE and checked by CI.
- shepherdjerred 2y agoYou can run Intellij's checks in CI: https://www.jetbrains.com/qodana/ https://www.jetbrains.com/qodana/
- mdaniel 2y agoI believe that's _conceptually_ possible but unless you, personally, have actually tried it I wouldn't go so far as to cite that. My hand's on experience was that the thing very easily gets into analysis loops and never terminates. And by "never" I mean that I dialed up the CI timeout to 24 hours just to see if I wasn't patient enough and it still didn't terminate And that's not even getting into the horror show of trying to view the analysis results of any "hello world" setup wherein it does terminate: a reasonable CI integration would submit those findings as comments on the PR but I had to duct tape one together by transforming the SERIF output into ReviewDog to get that outcome I am quite possibly the biggest JetBrains fanboy you'll encounter, and was thrilled out of my mind when they announced Qodana, but its execution has been a raging dumpster fire
- shepherdjerred 2y agoI am puzzled that you had such a negative experience. I set this up in the summer and it worked just fine, including comments on PRs. I used https://github.com/JetBrains/qodana-action https://github.com/JetBrains/qodana-action
- SvenL 2y agoInteresting. I always hear "you don't need a full blown IDE, vscode/neovim/other text editor should be enough". Then I read those articles about which plugins/bundles/addons I need to install and I wonder at which point do we call it IDE instead of text editor (with plugins).
- imron 2y agoMy .exrc file is about 10 lines long and has no plugins. Combined with ctags and a terminal it’s all I need for the languages I’m familiar with (c, c++, rust, python and several others)
- TacticalCoder 2y ago> I wonder at which point do we call it IDE instead of text editor The most hilarious to me is when people refer to Emacs as a "text editor". I'm not talking about the fact that Emacs shall happily display pictures (inlined in a file like in org-mode for example or in their own window), open binary files, open PDF files, manipulate files over SSH (Tramp), etc. Heck, as a statement some made Emacs run as PID 1. But many seem to honestly think Emacs is "notepad with bad shortcuts".
- ramon156 2y agoThere are people out there who don't even use an LSP with autocompletion or type handling, just syntax highlights. There's a theory that actively thinking about this will prevent u from making mistakes like forgetting a semicolon. I do agree that some nvim setups are just IDE's in your shell, but it's also nice to have everything in one place. I don't like vsc's and Jetbrains's terminals at all, as it gets clunky too quick. To each their own though!
- Myrmornis 2y agoNot specifically about Neovim, but I'm curious about the Java situation in general. To a first approximation IntelliJ is what everyone uses. I'm a VSCode user for everything but it seems basically the wrong decision to try to not use IntelliJ for Java. And mixed Kotlin/Java projects are impossible currently in VSCode with the RedHat extension. So my question is, what are projects like Cursor going to do? Surely the solution isn't to assume that JetBrains will do enough innovation in AI IDE features in the next year or two to prevent is wanting to try out all the other AI IDE innovation?
- mr_tristan 2y agoRight now, I’d say the “AI IDEs” like Cursor or Zed are ready to replace less Java-centric environments. I’d put VSCode in this “not really Java centric” bucket. I see VSCode as a “fancy text editor” for Java, i.e., better than an editor like Neovim, but, not by much. So, an AI IDE is more likely going to gain traction on people who have been using VSCode or Neovim than anyone using Eclipse or IntelliJ. Recently, my company has tried to introduce a “cloud IDE” (the development environment runs in the cloud somewhere). Initially, it only supported VSCode. The only engineers that bothered using it were junior; once people had about 5+ years of experience, they just found it tedious. Once the company included IntelliJ for that cloud IDE, usage spiked massively. (To the point they are restricting usage due to cost.) These “classic Java IDEs” just launch with features useful for understanding large systems, like, fast navigation and debugging capabilities. Things like “where is method used” or “what implements this interface method” is fast and accurate - i.e., not based on text search. Or the interactive debugger that lets you inspect stream state, track objects, etc. JetBrains probably won’t be focusing on using AI simply for writing code, but for enhancing all of these other capabilities. This is where I’m not sold on Cursor or Zed replacing these truly language-specific IDEs… yet. These new upstarts need to improve the ability to navigate and understand. Right now, they only seem to focus on writing, which I don’t think is what’s going to gain traction. I also don’t see any of them doing much other than just fancy autocomplete, which can be awful on a large legacy codebase. So… we’ll see. This could be generational, I’ve definitely seen poorer DevEx win simply because they gained the attention of younger engineers and lasted long enough.
- JavierFlores09 2y ago
- nelup20 2y agoI like the idea of LSPs and have tried switching to Vim/Neovim/Emacs a few times, but Jetbrains' refactoring/intellisense is just so much better imo
- atomicnumber3 2y agoOne thing that non-Java devs don't get is just how much better the tooling is for Java than literally any other language. Most jetbrains IDEs I find are indeed comparable to vscode plug-ins and a huge glob of vim plug-ins for most languages, especially the dynamically typed ones where the amount of static analysis you can do is already quite limited. But for IntelliJ, literally no other editor comes close. Extract method/variable, all the "hey you wrote java 6 but it's 2024 that those 6 lines you wrote are 1 lambda now, do you want to replace", and so many other things. Did you know that if you paste a maven xml dependency coordinate into a .gradle file, it auto-translates it to gradle format before the paste?
- Kwpolska 2y agoJetBrains Rider for C# is equally awesome. And you don't need to paste XML snippets for dependencies, it's in the GUI.
- neonsunset 2y agoNowadays, the package management can also be easily done with CLI: dotnet add package GxHash dotnet remove package ...
- freedomben 2y agoThis is absolutely true, but having spent a lot of time The Java ecosystem and then much time outside of it, I now think this is a bit of a curse. It has made the average Java developer actually structure their code and build practices around the IDE, rather than the other way around. If it wasn't for modern CI practices which force a headless build, I wouldn't be surprised if most Java projects wouldn't even build without the IDE to do the building for them. In several places I worked, Even That wasn't really usable outside of the CI environment because it was just taped together as an afterthought and bare minimum since all the developers just used IntelliJ to build locally anyway. Even little things like variable naming, explicit types, and the like were commonly neglected because in the IDE you could just hover your mouse over the variable to see its type. Because that exists and is so commonly used, developers didn't even think about The impact it might have on someone not using the same IDE. This is just one of several practices that I continually ran into when trying to use vim. There are also plenty of readability issues, such as enormously long methods that the IDE collapses for most developers so they never see it and don't have to think about it, but once you aren't using that IDE anymore, you really see all the nastiness and warts. So long story short, I agree with you about the tooling, but I think it is actually more of a curse than most people realize.
- tofflos 2y ago> I’ll preface this by saying that if Neovim isn’t your primary editor, you should first try an IDE specifically for Java." Seconded. As someone who has spent a lot of time configuring editors, but doesn't enjoy it quite as much as he used to, I gave Java on Neovim a shot this summer. There are two main routes to go - both of which are described in the article. Either install it yourself, "You read the friendly manual", or use someone else's installer, "You use a distro". My problem with someone else's installer is that I don't understand what it's doing, which in turn gives me the feeling that it's pulling in the kitchen sink, which is exactly the feeling I hoped to avoid by not using my regular IDE. My problem with installing it myself is that I have to learn the entire ecosystem including, but not limited to, learning how to use Neovim for more than editing a simple text file, learning the Lua scripting language, learning where Neovim keeps its' configuration files and what to put in them, curating a set of plugins for highlighting, launching code, debugging, etc., figuring out how to configure those plugins for Neovim and finally how to make those plugins play nice together. In the end it just wasn't for me but if Neovim is your primary editor it might be for you. > Java has one LSP option for Neovim, and that’s JDTLS (Java Development Tools Language Server) by Eclipse. Just wanted to mention that there is another LSP for Java, https://github.com/apache/netbeans/tree/master/java/java.lsp.server https://github.com/apache/netbeans/tree/master/java/java.lsp..., but I don't know if anyone has gotten it to work with Neovim.
- jitl 2y agoI’ve tried out a few distros for vim and emacs over the years and usually drop them after a few hours of trying. But I gotta say I’m really enjoying LazyVim. It’s config layering system makes tweaking any specific plugin settings very easy, and it’s based on the “lazy.nvim” plugin manager that most plugins feature first in their README intros these days. That means there’s less a feeling of doing things “the normal way” vs “the weird distro specific way” that I experienced with DOOM EMacs and SpaceVim. It’s definitely still a kitchen sink, lots of stuff that I wouldn’t configure on my own, but surprisingly discoverable via a popup that shows available keyboard shortcuts that appears after you type LEADER and wait a moment. It’s also super fast to start up, putting most destros out there especially EMacs ones to shame. The main downside is it encourages you to spread out your config in multiple Lua files, and overall learn and use more Lua stuff. But I think it’s worth the price.
- deleted 2y ago[deleted]
- cess11 2y agoI pay out of my own pocket for Intellij, in case I want to build something that could make money and because contemporary Java is pretty ergonomic and suitable for some prototyping. But I also maintain a vim config for Java development, because in small projects and some small fixes it has a nicer integration with the shell and cli tools there. If you aren't going to do JavaFX, hairy debugging or non-trivial release management it's good enough.
- carlinm 2y agoThe hardest part for me in using nvim for java is the debugger tooling. I primarily use IntelliJ for any JVM related languages, and the debugger has always been invaluable. The debugging has always felt more polished and easy to configure in JetBrains IDEs. The nvim-dap and nvim-dap-ui had a bit too much friction to configure for it to my liking, and inevitably I reverted to IntelliJ. However, I love the keyboard-driven flow I can achieve in nvim where JetBrains IDEs fall short.
- giancarlostoro 2y agoWhat kills me with JetBrains is they work on a barely functional (according to vim coders I talk to) simulation plugin, instead of just investing resources into integrating Neovim as a backend via plugin. You can literally have all the niceness of JetBrains IDEs with the editing power of Neovim. That alone would flip so many die hard Vim users.
- TiredOfLife 2y ago> That alone would flip so many die hard Vim users. It wouldn't. Diehard Vim and Emacs users might hate each other, but they hate IDEs more.
- giancarlostoro 2y agoI had a few people who wanted the better IDE, but they hated the keybinding hell they were going through. Having a true integration would have flipped them fully.
- The_Colonel 2y agoThe problem there is that you'd be integrating two massive codebases, each with different expectations, assumptions etc. No matter how hard you try, they'd clash in places and some things would not work, leaving one side or another unhappy even with this massive effort. IdeaVim makes it work by having a massively simplified vim-like editor, specifically written for IntelliJ.
- 77pt77 2y agoNo. I don't whant to write Java, let alone in *vim.
- mdaniel 2y agoRelevant: Ask HN: Programmers who don't use autocomplete/LSP, how do you do it? - https://news.ycombinator.com/item?id=42492508 https://news.ycombinator.com/item?id=42492508 - Dec 2024 (625 comments)
- rubyn00bie 2y agoI switched to IntelliJ and use their vim bindings package, maybe 6 years ago now, exactly because of Java and other “IDE dependent” languages. I got really tired of switching between editors and IDEs and wanted “one to rule them all.” IntelliJ isn’t perfect but it’s pretty damn close to be honest. I admittedly use only a sliver of the features available in it but it also “just works.” And if when I switch languages, and use one heavily dependent on the IDE, I’m pretty much able to be productive immediately. Additionally, I have access to their language specific IDEs and can be off and running with them in a minute or two tops after some copy/pasta of settings (though I wish I didn’t have to do this step). P.S. If you want to give IntelliJ a try, after installing the vim bindings package, also make sure to install the “string manipulation” package, and set some keybindings, as it’s 100% necessary for quick editing.
- gorset 2y agoThere's a lot of ceremony to run jdtls! I find it easier to just install language servers using brew. Then the command can be simplified to cmd = { 'jdtls', '-data', home_dir .. '/.local/state/jdtls/' .. project_name }, My ftplugin/java.lua is about 100 lines, with most of it being settings and key bindings.
- nobleach 2y agoI feel the exact same way. I've had various iterations of this ftplugin for a couple of years now but... everyone else has figured out how to just install an LSP and move on. Why is Java such a special snowflake here?
- helsinki 2y agoInteresting. JVM langs are the only ones I don't write in Neovim, due to abysmal support (namely, Metals). I'll go through your instructions.
- samgranieri 2y agoI’m a big neovim fan, and I I ever need to do Java, first I’ll enable the Java lang extra in lazyvim . If that doesn’t work I’d look at this and make changes. Then I’d probably go to IntelliJ Idea.
- ghm2180 2y agoHere is what I would do to even approach this 1. Note all the things you like about your current IDE vis-a-vis your development workflow. 5 major Lists will emerge : While Code, While Compiling, While Running, Debugging & Test. 2. Set up a current project you are working on in the IDE in neovim. 3. Take some minutes in the day how much cognitive load it takes to switch and use each one of the things in #1. Then ask yourself the 1million $$$$ Question: - Does adding a bit of complexity give you an advantage? - This will probably teach you more about your own current IDE and improvements you could do there than neovim
- codr7 2y agoI write most of my code in Emacs, even C# because I find VS* to be a major pain in the ass. But I've always used IDEs to write Java, first Eclipse and lately IntelliJ. They are simply nicer to work in than anything else I've tried, except Smalltalk and Lisp machines. I have a feeling it came as part of the cultural heritage from Smalltalk.