spacevim/docs/layers/lang/java.md
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

5.1 KiB

title description
SpaceVim lang#java layer This layer is for Java development. All the features such as code completion, formatting, syntax checking, REPL and debug have be done in this layer.

Available Layers >> lang#java

Description

This layer is for Java development.

Feature

  • code completion: autocomplete layer
  • code formatting: format layer
  • refactoring
  • syntax checking: checkers layer
  • REPL(requires jshell)
  • code runner
  • debug: check out the debug layer

Install

To use this configuration layer, update your custom configuration file with:

[[layers]]
  name = "lang#java"

Layer options

  • format_on_save: Enable/disabled code formatting when saving current file. The default value is false. To enable this feature:
    [[layers]]
      name = 'lang#java'
      format_on_save = true
    
  • java_formatter_jar: Set the full path of google's formater jar.
    [[layers]]
      name = 'lang#java'
      java_formatter_jar = 'path/to/google-java-format.jar'
    
  • java_file_head: The default file header for new java file. by default it is:
    [[layers]]
      name = 'lang#java'
      java_file_head = [
        '/**',
        ' * @author : `fnamemodify(expand("~"), ":t")`',
        ' * @created : `strftime("%Y-%m-%d")`',
        '**/',
        ''
      ]
    

Key bindings

Import key bindings

Key Bindings Descriptions
SPC l I Import missing classes
SPC l R Remove unused classes
SPC l i smart import class under cursor
Ctrl-j I (Insert) Import missing classes
Ctrl-j R (Insert) Remove unused classes
Ctrl-j i (Insert) smart import class under cursor

Generate key bindings

Mode Key Bindings Descriptions
normal SPC l g A generate accessors
normal/visual SPC l g s generate setter accessor
normal/visual SPC l g g generate getter accessor
normal/visual SPC l g a generate setter and getter accessor
normal SPC l g M generate abstract methods
insert Ctrl-j s generate setter accessor
insert Ctrl-j g generate getter accessor
insert Ctrl-j a generate getter and setter accessor
normal SPC l g t generate toString function
normal SPC l g e generate equals and hashcode function
normal SPC l g c generate constructor
normal SPC l g C generate default constructor

Code formatting

The default formater of java language is google's formater jar. You need to download the jar and set the java_formatter_jar layer option.

The default key bindings for format current buffer is SPC b f. And this key binding is defined in format layer. You can also use g= to indent current buffer.

Maven support

Key Bindings Descriptions
SPC l m i Run maven clean install
SPC l m I Run maven install
SPC l m p Run one already goal from list
SPC l m r Run maven goals
SPC l m R Run one maven goal
SPC l m t Run maven test

Gradle support

Key Bindings Descriptions
SPC l a b gradle build
SPC l a B gradle clean build
SPC l a r gradle run
SPC l a t gradle test

Code runner

Key bindings Descriptions
SPC l r m run main method of current file
SPC l r m run the current method
SPC l r t run all test methods

Inferior REPL process

Start a jshell inferior REPL process with SPC l s i.

Send code to inferior process commands:

Key Bindings Descriptions
SPC l s b send buffer and keep code buffer focused
SPC l s l send line and keep code buffer focused
SPC l s s send selection text and keep code buffer focused