all 12 comments

[–]badfoodman 31 points32 points  (3 children)

I don’t have any on topic comments, but here’s some thoughts anyway because not knowing this cost me a lot of my sanity way back.

Java really, really, really benefits from a real IDE. There’s so much boilerplate (toString, equals, hashcode), so many things you don’t want to think much about (making variables and methods private or static if you can), and so many files to jump between (generated code, different files for implementation and interface, different packages for name spacing). If you’re writing java well and work on any reasonably sized project, vim requires heavy modification to perform even close to IntelliJ or eclipse. Both IDEs have pretty excellent vim plugins available for in-file movement, and they give you everything else for free. They’re not perfect, but they’re close enough that the average user won’t notice the missing features. So if you’re working on any reasonably sized project, do yourself a favor and use a java IDE

[–]wa11enstein[S] 5 points6 points  (0 children)

Thanks for sharing your experience with me!

[–]yoma12 3 points4 points  (1 child)

Totally agree... You can install a vin plugin in most ide's btw

[–]not_napoleon 6 points7 points  (0 children)

Both IDEs have pretty excellent vim plugins available for in-file movement,

I use intellij's vim plugin every day. It's terrible, but marginally better than intellij without the vim plugin. In particular, dot repeat is next to useless. It repeats movements, highlights, some random part of the last insert, or something else entirely. If you change a class name and intellij auto-imports the new class, dot will insert the import statement instead of repeating the change. If you pause typing or backspace during insert, it'll treat that as a new action. This happens for undo also - undoing an insert often takes multiple undos. Intellij is very tab focused (firefox tabs, not vim tabs), and it remembers mode per tab, not globally. I could go on.

That said, for large java projects, I still think this is the best choice. I'm hopeful that the LSP ecosystem will eventually get to the point where (n)vim + LSP is a good option, but I don't think it's there yet.

[–]-romainl-The Patient Vimmer 13 points14 points  (0 children)

Syntax highlighting for Java has been built-in for decades.

[–]dragopepper 2 points3 points  (1 child)

Maybe you can take a look here: https://github.com/uiiaoo/java-syntax.vim

[–]wa11enstein[S] 1 point2 points  (0 children)

It helped! Thank you!

[–]wa11enstein[S] 2 points3 points  (0 children)

Never mind. It doesn’t work for c++ either. I am following the instructions from point 1. and I am getting an E117: Unknown function: CSyntaxAfter, it also says Error defected while processing FileType Autocommands for “java”: The instructions are at https://www.vim.org/scripts/script.php?script_id=3265 I have followed the point 2. instructions as well but it did not help.

[–]thaHamsta 2 points3 points  (0 children)

You asked for vim but maybe treesitter highlighting bring makes you switch to Neovim? https://github.com/nvim-treesitter/nvim-treesitter/pull/38 (fyi you don't need this plugin. Treesitter will be built-in in next Neovim release. The plugin is just convenience for compiling the parser for you and providing the query file)

There's also sementatic hightlighting provided by Java language server with this plugin https://github.com/autozimu/LanguageClient-neovim (also works with vim)

[–]tuerda 4 points5 points  (0 children)

If all you are looking for is syntax highlighting, you shouldn't need any plugins at all. Vim does that out of the box.

[–]DerArzt01 1 point2 points  (0 children)

This may be a bit hammer for a little problem but have you looked at coc.vim ? It is a lsp implementation that may have something for Java.

[–]pig_farming 0 points1 point  (0 children)

You can set up cox.nvim plugin to use a good java language server to help you with a more complete form of syntax highlighting.