You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before:
buffer --> /tmp/file --> formatter --> /tmp/file --> buffer
Now (with 'stdin': 1):
buffer --> formatter --> buffer
Removed job_control as it isn't necessary
Adjusted formatters that support stdin to have stdin option set to 1.
Copy file name to clipboardExpand all lines: README.md
+59-19Lines changed: 59 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,18 @@
2
2
3
3
A [Neovim](https://neovim.io) and Vim8 plugin for formatting code.
4
4
5
-
Neoformat uses a variety of formatters for differing filetypes. Currently, Neoformat
6
-
will run a formatter _asynchronously_, and on success it will update the current
7
-
buffer with the formatted text. On a formatter failure, Neoformat will try the next
8
-
formatter defined for the filetype.
5
+
Neoformat uses a variety of formatters for many filetypes. Currently, Neoformat
6
+
will run a formatter using the current buffer data, and on success it will
7
+
update the current buffer with the formatted text. On a formatter failure,
8
+
Neoformat will try the next formatter defined for the filetype.
9
9
10
-
The job control is based off [vim-go's](https://github.com/fatih/vim-go).
10
+
By using `getbufline()` to read from the current buffer instead of file,
11
+
Neoformat is able to format your buffer without you having to `:w` your file first.
12
+
Also, by using `setline()`, marks, jumps, etc. are all maintained after formatting.
13
+
14
+
Neoformat supports both sending buffer data to formatters via stdin, and also
15
+
writing buffer data to `/tmp/` for formatters to read that do not support input
16
+
via stdin.
11
17
12
18
## Basic Usage
13
19
@@ -33,28 +39,33 @@ Plug 'sbdchd/neoformat'
33
39
34
40
## Current Limitation(s)
35
41
36
-
In order to preserve marks, jumps, etc., Neoformat uses Vim's `setline()` function
37
-
to insert the formatted text. If the buffer is changed before the formatter has
38
-
completed, then the updated text will be put into the current buffer.
39
-
40
-
To prevent this, format jobs are cancelled when changing / closing the buffer.
42
+
If a formatter is either not configured to use `stdin`, or is not able to read
43
+
from `stdin`, then buffer data will be written to a file in `/tmp/neoformat/`,
44
+
where the formatter will then read from
41
45
42
-
**So don't switch buffers before the the formatting is complete!**
43
-
44
-
Note: This should be resolved when [`setbufline()`](https://github.com/vim/vim/blob/9bd547aca41799605c3a3f83444f6725c2d6eda9/runtime/doc/todo.txt#L177) is added.
46
+
## Config [Optional]
45
47
46
-
By default, Neoformat reads from the current buffer, not the current file. This
47
-
can be changed via the configuration variable `g:neoformat_read_from_buffer`.
48
+
Define custom formatters.
48
49
49
-
With Vim, some of the formatters do not function, e.g. remark.
0 commit comments