Commit Graph

54 Commits

Author SHA1 Message Date
fbd00b6a08 fix(format): correct name of feature 2023-11-27 09:37:11 -05:00
9da33cf9e7 docs(format): describe interaction between +onsave and LSP 2023-11-27 09:37:11 -05:00
9d8f657b37 refactor(format): describe what hook does 2023-11-27 09:36:58 -05:00
cdbf97b4e9 fix(format): align behaviour and documentation
`+format-on-save-disabled-modes` documentation was referencing behaviour
that no longer exists, as well as documenting behaviour that was not
implemented.
2023-11-27 09:36:58 -05:00
a4d95674ec tweak(format): doom-debug-variables: add apheleia-log-only-errors 2023-09-20 20:23:59 +02:00
cdbf58a871 refactor(format): swap to string-blank-p & memq 2023-09-20 20:23:59 +02:00
aab5215951 fix(format): use +vc-gutter-update-h instead
+vc-gutter-init-maybe-h is not defined when using +diff-hl so instead
let's use +vc-gutter-update-h to refresh the VC gutter.
2023-09-16 05:00:25 +02:00
ce93f899fd fix(format): improve function/module loading safety 2023-09-13 20:21:08 +01:00
12d520a377 fix(format): remove merged formatter 2023-09-13 20:21:07 +01:00
b0e579741e fix(format): react to ns change 2023-09-13 20:21:07 +01:00
550767efe2 fix(format): apheleia-inhibit-functions after load 2023-09-13 20:21:07 +01:00
b34533de96 fix(format): load format-on-save-disabled-modes fn
Should handle some corner cases with how inhibiting is set
2023-09-13 20:21:07 +01:00
457aeeccc0 fix(format): better handle format-on-save disable 2023-09-13 20:21:07 +01:00
dc3b5c3710 fix(format): handle git-gutter nicely 2023-09-13 20:21:01 +01:00
cd79edf134 feat(format): add :lang emacs-lisp formatter
Introduce a formatter function for emacs-lisp (tracked upstream here
[1]) that tries to preserve as much of what the user wants as possible

[1]: https://github.com/radian-software/apheleia/pull/102
2023-09-13 20:20:58 +01:00
4ecd616cd8 refactor(format): replace with apheleia
Initial refactor of format module to replace format-all with apheleia
2023-09-13 20:19:59 +01:00
ad6a3d0f33 refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00
4549b275f2 fix(format): format-all-mode not activating
Also makes format-all log more when doom-debug-mode is on.

Fix #5589
2021-10-06 13:58:16 +02:00
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
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
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
33dbae7cb2 Fix format-all formatters not activating on save 2021-05-28 00:11:28 -04:00
005a71e467 Fix #5104 (again): void-function +format-lsp-enable-on-save-maybe-h 2021-05-27 19:32:56 -04:00
c9653ba8ae Fix #5104: void-function +format-lsp-enable-on-save-maybe-h 2021-05-27 12:51:56 -04:00
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
31ca03c7a0 editor/format: never prompt for formatter on init 2021-05-22 14:21:45 -04:00
b0e59ccdcc Fix #5030: leave rustfmt to :editor format 2021-05-11 17:00:11 -04:00
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
61376a2ca0 Fix #5001: disable formatter in org-msg-edit-mode 2021-05-07 14:17:04 -04:00
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
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
30c29cacf1 Update config.el 2020-10-20 18:33:31 +05:30
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
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
c2a0ac8b3e Fix #2605: update editor/format module 2020-03-10 01:48:20 -04:00
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
c795a988e6 Conform many modules to new conventions 2019-07-23 12:30:47 +02:00
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
84fd744e3f Minor, general refactor & comment revision 2019-06-14 11:08:59 +02:00
12233811a8 fix: format-all upstream definitions
Upstream renamed definitions in
f3ed09c430 .
2019-06-08 17:45:42 +02:00
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
bd39ff3526 Minor reformatting 2018-09-13 19:15:16 -04:00
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
3c34ff003b editor/format: override format-all-buffer w/ +format/buffer 2018-09-09 09:58:22 -04:00
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
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
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
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
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
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