Currently the user has to select `SPC c F` for lsp format. But if
lsp-mode is enabled, the user will always want to use the LSP formatter.
So this changes the default `SPC c f` to use lsp formatter if available.
This simplifies the interface a bit so the user doesn't have to worry
about selecting the "right" format, just like how other commands get
auto bound to LSP functions.
Make +format-buffer copy all buffer-local variables from the original buffer into the temporary buffer. When resolving a symbol inside of a formatter, the value it is bound to in the formatted buffer will now be used instead of the default value. Fixes#2036.
Currently `+format-completing-read` returns a cons cell like `(symbol . t)`, where `+format/buffer` expects a symbol. This commit makes `+format-completing-read` return a symbol instead. Fixes#2349.
The fix for #1489 (in 13f5a762) gives the temp buffer (where formatting
is performed) a real buffer-file-name, which causes it to prompt to save
it when it is killed.
+ Change +format-type to +format-region-p (now a boolean)
+ Add PRESERVE-INDENT-P boolean argument to +format-buffer
+ Add +format-preserve-indentation variable (only controls indent
preservation during +format/buffer, not +format/region, where it's
always enabled).
+ Fix error arising from +format|buffer hook when no formatter is
defined for the current mode #893
+ Change +format|buffer to alias for +format/buffer.
In case we need a conditional to test against in our formatters. e.g. in
go-mode, goimports is incompatible with partial formatting, so we force
it to use gofmt in that case.
+ A formatter can now be specified explicitly buffer-locally by setting
+format-with to a symbol representing the name of the
formatter (accepts any key of format-all-format-table)
+ Passing C-u to any of +format/buffer, +format/region or
+format/region-or-buffer will now prompt you to select a formatter.
+ Revise docstring for +format-on-save-enabled-modes
This redesigns how format-all applies changes. Before, it would erase
the buffer and insert the formatted result. This would throw markers out
of whack, and usually meant the cursor would end up somewhere else (e.g.
the beginning of the file).
Now, changes are made to the buffer line by line, via RCS patch.
Other changes:
+ +format-region function was removed (replaced by +format-buffer and
+format/region).
+ set-formatter! was moved to autoload/settings.el
+ New +format/buffer command to replace format-all-buffer
Also renames +format|on-save to +format|buffer for clarity. It should
not (normally) be used directly. Use `+format|enable-on-save-maybe` and
`+format|enable-on-save`.
+ Fixes function/command formatters (like #'gofmt)
+ Fixes formatting by region
+ Adds default keybindings:
+ gQ evil operator
+ SPC c f (normal mode) to format buffer
+ SPC c f (visual mode) to format selection