The actual uncrustify link points to astyle :-)
4.2 KiB
title | categories | excerpt | redirect_from | type | comments | commentsID | ||
---|---|---|---|---|---|---|---|---|
Use Vim as a Java IDE |
|
A general guide for using SpaceVim as Java IDE, including layer configuration and requiems installation. | /2017/02/11/use-vim-as-a-java-ide.html | BlogPosting | true | Use Vim as a Java IDE |
Blogs >> Use Vim as a Java IDE
This is a general guide for using SpaceVim as a Java IDE, including layer configuration and usage. Each of the following sections will be covered:
- Installation
- Code completion
- Syntax lint
- Import packages
- Jump to test file
- running code
- Code formatting
- REPL
Installation
SpaceVim is a Vim and neovim configuration, so you need to install vim or neovim,
here are two guides for installing neovim and vim8 with +python3
feature.
following the quick start guide to install SpaceVim.
SpaceVim do not enable language layer by default, so you need to enable lang#java
layer.
Press SPC f v d
to open SpaceVim configuration file, and add following section:
[[layers]]
name = "lang#java"
Code completion
javacomplete2 which has been included in lang#java
layer provides omnifunc for java file and deoplete source.
with this plugin and autocomplete
layer, the completion popup menu will be opened automatically。
Syntax lint
checkers
layer provides asynchronous linting feature, this layer use neomake by default.
neomake support maven, gradle and eclipse project. it will generate classpath automatically for these project.
within above picture, we can see the checkers layer provides following feature:
- list errors and warnings in quickfix windows
- sign error and warning position on the left side
- show numbers of errors and warnings on statusline
- show cursor error and warning information below current line
Import packages
There are two kind features for importing packages, import packages automatically and manually. SpaceVim will import the packages after selecting the class name on popmenu.
Also, you can use key binding <F4>
to import the class at the cursor point. If there are more than one class, a menu will be shown below current windows.
Jump to test file
SpaceVim use vim-project to manager the files in a project, you can add a .projections.json
to the root of your project with following content:
{
"src/main/java/*.java": {"alternate": "src/test/java/{dirname}/Test{basename}.java"},
"src/test/java/**/Test*.java": {"alternate": "src/main/java/{}.java"}
}
with this configuration, you can jump between the source code and test file via command :A
running code
Base on JavaUnite, you can use SPC l r c
to run current function or use SPC l r m
to run the main function of current Class.
Code formatting
For formatting java code, you also nEed have uncrustify or astyle in your PATH. BTW, the google's java formatter also works well with neoformat.
REPL
you need to install jdk9 which provide a build-in tools jshell
, and SpaceVim use the jshell
as default inferior REPL process: