1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 02:05:40 +08:00

Fix visual mode code format (#3866)

This commit is contained in:
Wang Shidong 2020-10-04 23:02:30 +08:00 committed by GitHub
parent 3f28bf4b87
commit e41ffa575f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 7 deletions

View File

@ -12,8 +12,14 @@
" format layer provides code formation for SpaceVim, the default formatting
" plugin is |neoformat|.
" @subsection options
" format_on_save: disabled by default.
"
" `format_on_save`: disabled by default.
"
" @subsection key bindings
" >
" Key binding Description
" SPC b f format current buffer or selection lines
" <
"
if exists('s:format_on_save')
@ -30,7 +36,7 @@ function! SpaceVim#layers#format#plugins() abort
endfunction
function! SpaceVim#layers#format#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['b', 'f'], 'Neoformat', 'format-code', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'f'], ":Neoformat\<Enter>", 'format-code', 0, 1)
augroup spacevim_layer_format
autocmd!
autocmd BufWritePre * call s:format()

View File

@ -1452,8 +1452,15 @@ FORMAT *SpaceVim-layer-format*
format layer provides code formation for SpaceVim, the default formatting
plugin is |neoformat|.
OPTIONS
format_on_save: disabled by default.
`format_on_save`: disabled by default.
KEY BINDINGS
>
Key binding Description
SPC b f format current buffer or selection lines
<
==============================================================================

View File

@ -6,7 +6,6 @@ lang: zh
# [可用模块](../) >> format
<!-- vim-markdown-toc GFM -->
- [模块简介](#模块简介)
@ -14,6 +13,7 @@ lang: zh
- [模块设置](#模块设置)
- [模块选项](#模块选项)
- [全局选项](#全局选项)
- [快捷键](#快捷键)
<!-- vim-markdown-toc -->
@ -60,11 +60,9 @@ lang: zh
### 全局选项
neoformat 是一个格式化框架插件,该插件的所有自身选项可以在启动函数中进行设置,可以预读 `:help neoformat`
`neoformat` 是一个格式化框架插件,该插件的所有自身选项可以在启动函数中进行设置,可以预读 `:help neoformat`
获取完整帮助。
以下是一个为 Java 文件设置格式化命令的配置,以下配置已经包含在 `lang#java` 模块内了:
```viml
@ -75,3 +73,9 @@ let g:neoformat_java_googlefmt = {
\ 'stdin': 1,
\ }
```
## 快捷键
| 快捷键 | 功能描述 |
| --------- | -------------------------- |
| `SPC b f` | 格式化当前文件或者选中内容 |

View File

@ -12,6 +12,7 @@ description: "Code formatting layer for SpaceVim, includes a variety of formatte
- [Configuration](#configuration)
- [Layer options](#layer-options)
- [Global options](#global-options)
- [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
@ -72,3 +73,9 @@ let g:neoformat_java_googlefmt = {
\ 'stdin': 1,
\ }
```
## Key bindings
| Key binding | Description |
| ----------- | ------------------------------------- |
| `SPC b f` | format whole buffer or selected lines |