mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 09:40:06 +08:00
2.0 KiB
2.0 KiB
title | description |
---|---|
SpaceVim format layer | Code formatting layer for SpaceVim, includes a variety of formatters for many filetypes |
Available Layers >> format
Description
format
layer provides code formatting feature for SpaceVim, this layer includes neoformat
as the default code formatting plugin.
Install
This layer is enabled by default. If you want to disable it, add the following to your configuration file:
[[layers]]
name = "format"
enable = false
Configuration
Layer options
-
format_on_save
: This 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, enableformat_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
Global options
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 to add a formater 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 bindings
Key binding | Description |
---|---|
SPC b f |
format whole buffer or selected lines |