SpaceVim
A modular Vim/Neovim configuration
Home | About | Quick start guide | Documentation | Development | Community | Sponsors | 中文
The format
layer provides code formatting for SpaceVim, with support for
neoformat
(default) and
codefmt
underlying code
formatting plugins.
This layer is enabled by default. If you want to disable it, add the following to your configuration file:
[[layers]]
name = "format"
enable = false
format_method
: The default plugin is neoformat
but can be changed to codefmt
:
[[layers]]
name = "format"
format_method = "codefmt"
format_on_save
: This layer option is to enable/disable code formatting when save current buffer,
and it is disabled by default. To enable it:
[[layers]]
name = "format"
format_on_save = true
This option can be overrided by format_on_save
in the language layer. For example, enable format_on_save
for all filetypes except python.
# enable format layer
[[layers]]
name = 'format'
format_on_save = true
# enable lang#java layer
[[layers]]
name = 'lang#python'
format_on_save = false
silent_format
: Setting this to true will run the formatter silently without any messages. Default is
disabled.
[[layers]]
name = "format"
silent_format = true
neoformat is a formatting framework, all of it’s options can be used in bootstrap function. You can read
:help neoformat
for more info.
Here is an example for add formatter for java file, and it has been included into lang#java
layer:
let g:neoformat_enabled_java = ['googlefmt']
let g:neoformat_java_googlefmt = {
\ 'exe': 'java',
\ 'args': ['-jar', '~/Downloads/google-java-format-1.5-all-deps.jar', '-'],
\ 'stdin': 1,
\ }
Key binding | Description |
---|---|
SPC b f |
format whole buffer or selected lines |
Powered by Jekyll