Commit graph

36 commits

Author SHA1 Message Date
Henrik Lissner
06392a723f refactor: rename orig-fn arg in advice to fn
A minor tweak to our naming conventions for the first argument of an
:around advice.
2021-08-04 01:53:12 -04:00
Ralf Beckmann
012b759e98 Fix #5128: No format-on-save by lsp-formatters
A call to `format-all--formatter-executable` with the formatter being
equal to `'lsp` or `'eglot` will return `nil`. Therefore, `funcall` was
never called in those cases.
2021-06-14 23:52:16 +02:00
Henrik Lissner
68b422c786 editor/format: redesign
This isn't the apheleia rewrite, just a redesign to fix the module's
current issues with its +onsave feature.

+ Rethinks how the formatter dispatches to lsp/eglot's formatter.
+ Stops format-all from being too imposing with its warnings.
+ Relies more on format-all-mode to control formatting-on-save.
+ Sidestep +format-buffer-a hackery when using lsp/eglot formatters.

Fixes #5121
Fixes #5128
Fixes #5133
2021-06-04 16:15:29 -04:00
Henrik Lissner
33dbae7cb2 Fix format-all formatters not activating on save 2021-05-28 00:11:28 -04:00
Henrik Lissner
005a71e467 Fix #5104 (again): void-function +format-lsp-enable-on-save-maybe-h 2021-05-27 19:32:56 -04:00
Henrik Lissner
c9653ba8ae Fix #5104: void-function +format-lsp-enable-on-save-maybe-h 2021-05-27 12:51:56 -04:00
Henrik Lissner
6e7a19a2f4 Enable formatter if LSP formatter is available
The :editor format module uses either the formatter available through an
LSP server or a formatter that the format-all package supports.  With
:editor (format +onsave), this formatter is triggered when a file is
saved. However, if no format-all formatter is available, this on-save
behavior is disabled, even if an LSP formatter is available. This fixes
that.
2021-05-26 21:45:00 -04:00
Henrik Lissner
31ca03c7a0 editor/format: never prompt for formatter on init 2021-05-22 14:21:45 -04:00
Henrik Lissner
b0e59ccdcc Fix #5030: leave rustfmt to :editor format 2021-05-11 17:00:11 -04:00
Henrik Lissner
857d266e72 Inhibit format-all in modes without a formatter
Should stop format-all's error from causing trouble in modes that don't
have a registered formatter, like mu4e, org-msg-edit-mode,
org-journal-mode, and others.
2021-05-10 04:43:35 -04:00
Henrik Lissner
61376a2ca0 Fix #5001: disable formatter in org-msg-edit-mode 2021-05-07 14:17:04 -04:00
Henrik Lissner
b2c4e0f168 editor/format: disable formatter for rustic-mode
rustic provides its own internal formatter. Using that instead of
format-all is more reliable for the moment.
2021-05-07 02:37:47 -04:00
Chris Rose
57e9b89b80 Suppress format-all-mode error when no formatter is available
Having this on renders it difficult to work with debug-on-error, since a
_lot_ of filetypes don't have formatters
2020-11-01 08:52:31 -08:00
S. Arjun
30c29cacf1
Update config.el 2020-10-20 18:33:31 +05:30
S. Arjun
41d9e4b161
Update config.el
Use LSP formatting when server supports 'textDocument/formatting'
Solves hlissner/doom-emacs#3626
2020-10-19 19:55:54 +05:30
Henrik Lissner
090a68ab8f
Add +format-with-lsp variable
To control whether or not to use LSP code formatter when it is
available.
2020-05-21 01:20:00 -04:00
Henrik Lissner
c2a0ac8b3e
Fix #2605: update editor/format module 2020-03-10 01:48:20 -04:00
Henrik Lissner
f1d622e0a4
editor/format: disable format-on-save for latex
latexindent causes disruptive 'Please enter text to be indented: (press
CTRL+D when finished)' prompts, and is effectively broken.
2019-10-22 19:21:19 -04:00
Henrik Lissner
c795a988e6
Conform many modules to new conventions 2019-07-23 12:30:47 +02:00
Henrik Lissner
20f66b7560
editor/format: use format-all-mode
Allows uses to disable format-on-save by disabling format-all-mode.

Supersedes #1441
2019-06-14 11:10:23 +02:00
Henrik Lissner
84fd744e3f
Minor, general refactor & comment revision 2019-06-14 11:08:59 +02:00
argo
12233811a8 fix: format-all upstream definitions
Upstream renamed definitions in
f3ed09c430 .
2019-06-08 17:45:42 +02:00
Henrik Lissner
6a44cf0124 editor/reformat: refactor & fixes
+ 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.
2018-09-18 15:19:50 -04:00
Henrik Lissner
bd39ff3526
Minor reformatting 2018-09-13 19:15:16 -04:00
Henrik Lissner
e3d590784c
editor/format: defer test for formatter
By deferring formatter predicates until formatting actually happens,
users won't have to reset the major mode to get formatting to work.
2018-09-09 09:58:22 -04:00
Henrik Lissner
3c34ff003b
editor/format: override format-all-buffer w/ +format/buffer 2018-09-09 09:58:22 -04:00
Henrik Lissner
8480f52081
editor/format: add +format-with option
+ 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
2018-09-09 09:58:22 -04:00
Henrik Lissner
7d3ffdff06
Remove third line in section headers
This is truly important stuff. We've saved many lives with this update.
2018-09-09 09:58:19 -04:00
Henrik Lissner
a33165d47a
editor/format: disable in sql-mode by default
sqlformat appears to be broken. It either throws an IndexError or
formats SQL incorrectly and/or poorly.
2018-08-31 12:44:24 +02:00
Henrik Lissner
cb5c9cc9ea
Don't autoformat emacs-lisp-mode buffers on save
This is much too unpredictable, considering the variable nature of elisp
indentation, and the possibility that certain functions and their indent
behavior may not be defined/declared when the file is being formatted.
2018-08-29 12:46:24 +02:00
Henrik Lissner
ed0cbc1323
editor/format: fix format-all-probe check
Returns '(nil nil) when there is no formatter for the current mode. This
is truthy, so we needed a better check.
2018-08-28 13:35:03 +02:00
Henrik Lissner
e932c74758
editor/format: don't move cursor on format-on-save
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`.
2018-08-28 12:02:56 +02:00
Henrik Lissner
3b69045ed4
editor/format: add +format|on-save buffer-locally 2018-08-26 17:31:14 +02:00
Henrik Lissner
f1460ff592
editor/format: don't move cursor on save 2018-08-26 17:26:54 +02:00
Henrik Lissner
6515a1c539
editor/format: fix +onsave 2018-08-25 01:10:47 +02:00
Henrik Lissner
f51f2948af
New :editor format module
Centralized code formatting with built-in support for a variety of
languages. Provides the set-formatter! function for defining your own.

Still experimental and needs more testing!
2018-08-22 02:20:11 +02:00