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
102 lines
2.4 KiB
Markdown
102 lines
2.4 KiB
Markdown
---
|
|
title: "SpaceVim format layer"
|
|
description: "Code formatting layer for SpaceVim, includes a variety of formatters for many filetypes"
|
|
---
|
|
|
|
# [Available Layers](../) >> format
|
|
|
|
<!-- vim-markdown-toc GFM -->
|
|
|
|
- [Description](#description)
|
|
- [Install](#install)
|
|
- [Configuration](#configuration)
|
|
- [Layer options](#layer-options)
|
|
- [Global options](#global-options)
|
|
- [Key bindings](#key-bindings)
|
|
|
|
<!-- vim-markdown-toc -->
|
|
|
|
## Description
|
|
|
|
The `format` layer provides code formatting for SpaceVim, with support for
|
|
[`neoformat`](https://github.com/sbdchd/neoformat) (default) and
|
|
[`codefmt`](https://github.com/google/vim-codefmt) underlying code
|
|
formatting plugins.
|
|
|
|
## Install
|
|
|
|
This layer is enabled by default. If you want to disable it, add the following to your configuration file:
|
|
|
|
```toml
|
|
[[layers]]
|
|
name = "format"
|
|
enable = false
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Layer options
|
|
|
|
- **`format_method`**: The default plugin is `neoformat` but can be changed to `codefmt`:
|
|
|
|
```toml
|
|
[[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:
|
|
|
|
```toml
|
|
[[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.
|
|
|
|
```toml
|
|
# 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.
|
|
|
|
```toml
|
|
[[layers]]
|
|
name = "format"
|
|
silent_format = true
|
|
```
|
|
|
|
### 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 for add formatter for java file, and it has been included into `lang#java` layer:
|
|
|
|
```viml
|
|
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 |
|