-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathneoformat.txt
More file actions
283 lines (244 loc) · 9.8 KB
/
neoformat.txt
File metadata and controls
283 lines (244 loc) · 9.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
*neoformat.txt* A Neovim plugin for formatting.
CONTENTS *neoformat-contents*
Introduction |neoformat-introduction|
Install |neoformat-install|
Usage |neoformat-usage|
Supported Filetypes |neoformat-supported-filetypes|
==============================================================================
INTRODUCTION *neoformat-introduction*
A [Neovim](https://neovim.io) and Vim8 plugin for formatting code.
*Neoformat* uses a variety of formatters for many filetypes. Currently, Neoformat
will run a formatter using the current buffer data, and on success it will
update the current buffer with the formatted text. On a formatter failure,
Neoformat will try the next formatter defined for the filetype.
By using `getbufline()` to read from the current buffer instead of file,
Neoformat is able to format your buffer without you having to `:w` your file first.
Also, by using `setline()`, marks, jumps, etc. are all maintained after formatting.
Neoformat supports both sending buffer data to formatters via stdin, and also
writing buffer data to `/tmp/` for formatters to read that do not support input
via stdin.
==============================================================================
INSTALL *neoformat-install*
Install with [vim-plug](https://github.com/junegunn/vim-plug)
>
Plug 'sbdchd/neoformat'
<
==============================================================================
USAGE *neoformat-usage*
Format the entire buffer, or visual selection of the buffer
>
:Neoformat
<Or specify a certain formatter (must be defined for the current filetype)
>
:Neoformat jsbeautify
Or format a visual selection of code in a different filetype
*Note:* you must use a ! and pass the filetype of the selection
>
:Neoformat! python
>
You can also pass a formatter to use
>
:Neoformat! python yapf
<
Or perhaps run a formatter on save
>
augroup fmt
autocmd!
autocmd BufWritePre * Neoformat
augroup END
<
==============================================================================
CURRENT LIMITATION(S) *neoformat-limitations*
If a formatter is either not configured to use `stdin`, or is not able to read
from `stdin`, then buffer data will be written to a file in `/tmp/neoformat/`,
where the formatter will then read from
==============================================================================
CONFIG *neoformat-config*
Define custom formatters.
Options:
| `exe` | the name the formatter executable in the path | required
| `args` | list of arguments | default: [] | optional
| `replace` | overwrite the file, instead of updating the buffer | default: 0 | optional
| `stdin` | send data to the stdin of the formatter | default 0 | optional
| `no_append` | do not append the `path` of the file to the formatter command,
used when the `path` is in the middle of a command | default: 0 |
optional
Example:
Define custom formatters.
>
let g:neoformat_python_autopep8 = {
\ 'exe': 'autopep8',
\ 'args': ['-s 4', '-E'],
\ 'replace': 1 " replace the file, instead of updating buffer (default: 0),
\ 'stdin': 1, " send data to stdin of formatter (default: 0)
\ 'no_append': 1,
\ }
let g:neoformat_enabled_python = ['autopep8']
<
Have Neoformat use &formatprg as a formatter
>
let g:neoformat_try_formatprg = 1
<
Enable basic formatting when a filetype is not found. Disabled by default.
>
" Enable alignment
let g:neoformat_basic_format_align = 1
" Enable tab to spaces conversion
let g:neoformat_basic_format_retab = 1
" Enable trimmming of trailing whitespace
let g:neoformat_basic_format_trim = 1
Have Neoformat only msg when there is an error
>
let g:neoformat_only_msg_on_error = 1
<
When debugging, you can enable either of following variables for extra logging.
>
let g:neoformat_verbose = 1 " only affects the verbosity of Neoformat
" Or
let &verbose = 1 " also increases verbosity of the editor as a whole
<
==============================================================================
ADDING A NEW FORMATTER *neoformat-adding-new-formatter*
Note: you should replace everything `{{ }}` accordingly
1. Create a file in `autoload/neoformat/formatters/{{ filetype }}.vim` if it does not
already exist for your filetype.
2. Follow the following format
See Config above for options
>
function! neoformat#formatters#{{ filetype }}#enabled() abort
return ['{{ formatter name }}', '{{ other formatter name for filetype }}']
endfunction
function! neoformat#formatters#{{ filetype }}#{{ formatter name }}() abort
return {
\ 'exe': '{{ formatter name }}',
\ 'args': ['-s 4', '-q'],
\ 'stdin': 1
\ }
endfunction
function! neoformat#formatters#{{ filetype }}#{{ other formatter name }}() abort
return {'exe': {{ other formatter name }}
endfunction
<
==============================================================================
SUPPORTED FILETYPES *neoformat-supported-filetypes*
- Arduino
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`astyle`](http://astyle.sourceforge.net)
- C
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`astyle`](http://astyle.sourceforge.net)
- C#
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`astyle`](http://astyle.sourceforge.net)
- C++
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`astyle`](http://astyle.sourceforge.net)
- Crystal
- `crystal tool format` (ships with [`crystal`](http://crystal-lang.org))
- CSS
- `css-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)),
[`prettydiff`](https://github.com/prettydiff/prettydiff),
[`stylefmt`](https://github.com/morishitter/stylefmt),
[`csscomb`](http://csscomb.com)
- CSV
- [`prettydiff`](https://github.com/prettydiff/prettydiff)
- D
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`dfmt`](https://github.com/Hackerpilot/dfmt)
- Dart
- [`dartfmt`](https://www.dartlang.org/tools/)
- Elm
- [`elm-format`](https://github.com/avh4/elm-format)
- Fish
- [`fish_indent`](http://fishshell.com)
- Go
- [`gofmt`](https://golang.org/cmd/gofmt/),
[`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports)
- Haskell
- [`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell)
- [`hindent`](https://github.com/chrisdone/hindent)
- [`hfmt`](https://github.com/danstiner/hfmt)
- HTML
- `html-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)),
[`prettydiff`](https://github.com/prettydiff/prettydiff)
- Jade
- [`pug-beautifier`](https://github.com/vingorius/pug-beautifier)
- Java
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`astyle`](http://astyle.sourceforge.net)
- Javascript
- [`js-beautify`](https://github.com/beautify-web/js-beautify),
[`prettier`](https://github.com/jlongster/prettier),
[`prettydiff`](https://github.com/prettydiff/prettydiff),
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`esformatter`](https://github.com/millermedeiros/esformatter/),
[`prettier-eslint`](https://github.com/kentcdodds/prettier-eslint-cli),
[`eslint_d`](https://github.com/mantoni/eslint_d.js)
- JSON
- [`js-beautify`](https://github.com/beautify-web/js-beautify),
[`prettydiff`](https://github.com/prettydiff/prettydiff)
[`jq`](https://stedolan.github.io/jq/)
- LaTeX
- [`latexindent`](https://github.com/cmhughes/latexindent.pl)
- Less
- [`csscomb`](http://csscomb.com),
[`prettydiff`](https://github.com/prettydiff/prettydiff)
- Lua
- [`luaformatter`](https://github.com/LuaDevelopmentTools/luaformatter)
- Markdown
- [`remark`](https://github.com/wooorm/remark)
- Objective-C
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`astyle`](http://astyle.sourceforge.net)
- OCaml
- [`ocp-indent`](http://www.typerex.org/ocp-indent.html)
- Pandoc Markdown
- [`pandoc`](https://pandoc.org/MANUAL.html)
- Pawn
- [`uncrustify`](http://uncrustify.sourceforge.net)
- Perl
- [`perltidy`](http://perltidy.sourceforge.net)
- PHP
- [`php_beautifier`](http://pear.php.net/package/PHP_Beautifier)
- Proto
- [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html)
- Pug (formally Jade)
- [`pug-beautifier`](https://github.com/vingorius/pug-beautifier)
- Python
- [`yapf`](https://github.com/google/yapf),
[`autopep8`](https://github.com/hhatto/autopep8)
[isort](https://github.com/timothycrosley/isort)
- Ruby
- [`ruby-beautify`](https://github.com/erniebrodeur/ruby-beautify)
- Rust
- [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt)
- Sass
- [`sass-convert`](http://sass-lang.com/documentation/#executables),
[`csscomb`](http://csscomb.com)
- Scala
- [`scalariform`](https://github.com/scala-ide/scalariform)
- SCSS
- [`sass-convert`](http://sass-lang.com/documentation/#executables),
[`stylefmt`](https://github.com/morishitter/stylefmt),
[`prettydiff`](https://github.com/prettydiff/prettydiff),
[`csscomb`](http://csscomb.com)
- Shell
- [`shfmt`](https://github.com/mvdan/sh)
- SQL
- `sqlformat` (ships with [sqlparse](https://github.com/andialbrecht/sqlparse))
- Typescript
- [`tsfmt`](https://github.com/vvakame/typescript-formatter)
- VALA
- [`uncrustify`](http://uncrustify.sourceforge.net)
- XHTML
- [`tidy`](http://www.html-tidy.org),
[`prettydiff`](https://github.com/prettydiff/prettydiff)
- XML
- [`tidy`](http://www.html-tidy.org),
[`prettydiff`](https://github.com/prettydiff/prettydiff)
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: