Commit Graph

101 Commits

Author SHA1 Message Date
50a2ba0586 fix(format): eglot format scratch buffer 2025-06-02 14:18:25 +02:00
4ca742a281 fix(format): lsp format scratch buffer
Apheleia wants the formatters to act on the `scratch` buffer
complains if `buffer` was modified.

Fix: #8182
2025-06-02 14:18:25 +02:00
dd493e48ed fix(format): wrong-type-argument listp error 2025-04-11 15:49:41 -04:00
c233aada0b fix(format): void-variable callback when formatting w/ lsp-mode
Ref: #8182
2025-04-10 19:12:51 -04:00
a0c901cca7 fix(format): lsp-mode/eglot formatters
There seems to be context that eglot needs that isn't available in
Apheleia's scratch buffer.

Fix: #7962
2024-08-22 12:32:14 -04:00
abf19aa63e tweak(format): +format/region: emit message on success 2024-08-20 16:36:22 -04:00
5e2e886b35 nit: comment revision & reformatting 2024-08-15 23:18:47 -04:00
13ed89f235 fix(format): disengage selection after +format-region
Fix: #7951
2024-07-16 11:34:14 -04:00
1eaa1aef2c refactor(format): rename to +format/org-blocks-in-region
To better reflect that it operates on multiple blocks.

Ref: #7936
2024-07-14 02:00:24 -04:00
7543b04e15 feat(format): add +format/org-block-in-region
Also updates `+org/reformat-at-point` to call
`+format/org-block-in-region` if selection is active.

Fix: #7936
2024-07-14 01:57:20 -04:00
081231b73f fix(format): apheleia doesn't invoke lsp formatter
change `+format--lsp-fn` to run `+format--lsp-fn` in context of main
buffer rather than apheleia's scratch buffer so that the lsp mode can
be discovered
2024-07-08 21:41:39 -04:00
6b526b1b47 refactor(format): +format/org-block: make arg optional 2024-07-07 21:48:17 -04:00
fd1941b95f refactor!(format): simplify & gate lsp/eglot impl behind +lsp
BREAKING CHANGE: This commit introduces two changes, a breaking, one
not.

The breaking change: `+format-with-lsp` used to control lsp-mode/eglot
integration for this module, but it is now gated behind a new +lsp flag.
Users will need to add it to their `doom!` blocks (in $DOOMDIR/init.el)
to restore the integration.

The other change: I've merged the former `lsp` and `eglot` formatters
into a single `lsp` formatter that dispatches to the appropriate
backend, as well as wrapping this integration in a
`+format-with-lsp-mode` minor mode, so it can be toggled at will; mainly
to assist in debugging formatter behavior.

A unified formatter makes it easier for folks to configure
`+format-with` on a per-project/directory/file basis, without needing to
know what backend this module uses, and opens us up to integrating other
LSP backends in the future (like lsp-bridge).
2024-07-07 21:43:27 -04:00
d648bfda40 docs(format): revise docstrings and comments 2024-07-07 20:41:03 -04:00
5e78ed0911 refactor(format): use eglot-server-capable
eglot--server-capable was deprecated.
2024-07-07 14:39:50 -04:00
17d4aaace3 fix(format): add lsp functions
Forgot to include these functions in 8072762. Oops.

Amend: 8072762de8
2024-07-06 21:03:12 -04:00
8072762de8 refactor(format): redesign module
Rather than wrap Apheleia in custom formatting logic, I now use
Apheleia's own machinary to integrate into LSP and Eglot, which is less
complexity to maintain. It also makes settings +format-with a more
reliable option for per-project or per-file configuration.

This also adds a +format/org-src-block command, which I'll incorporate
into the org module in a follow-up commit.

Ref: #7685
2024-07-06 19:54:55 -04:00
5cc4056abf fix(format): +format-with-eglot-fn: eglot detection 2024-03-13 01:00:38 -04:00
5c7149da67 docs(format): +format-in-org-src-blocks-fn: add docstring 2024-02-17 07:13:39 -05:00
1e8fd09120 fix(format): +format-in-org-src-blocks-fn
Didn't return non-nil, so whether or not it worked, Apheleia would
attempt to (ineffectually) format the org buffer afterwards.

Also remove unneeded beg/end checks (the functions always receive a
value).
2024-02-17 07:13:39 -05:00
9ba6d7191c refactor(format): improve lsp/eglot formatter dispatchers 2024-02-14 18:12:22 -05:00
e9ea3cc591 feat(format): add eglot support
Fix: #7673
2024-02-14 18:12:22 -05:00
20de3d0f29 refactor(format): introduce +format-functions 2024-02-14 18:12:22 -05:00
659f7bfc71 refactor!: deprecate IS-* OS constants
BREAKING CHANGE: This deprecates the IS-(MAC|WINDOWS|LINUX|BSD) family
of global constants in favor of a native `featurep` check:

  IS-MAC      ->  (featurep :system 'macos)
  IS-WINDOWS  ->  (featurep :system 'windows)
  IS-LINUX    ->  (featurep :system 'linux)
  IS-BSD      ->  (featurep :system 'bsd)

The constants will stick around until the v3 release so folks can still
use it -- and there are still some modules that use it, but I'll phase
those uses out gradually.

Fix: #7479
2024-02-04 17:54:29 -05:00
9a1022ef08 bump: :editor format
radian-software/apheleia@c222927f70 -> radian-software/apheleia@56651724ad

fbd00b6 changes aphelia-core to aphelia, but only in 1 out of 2 places
and this is not the correct name in the version pinned in doom.

Fix: #7568
Amend: fbd00b6a08
2023-11-29 11:27:06 -05:00
7920b0d46c fix(format): update missing values & set buffer modification
This prevents apheleia complaining about the editing buffer being
killed.

Co-authored-by: Wang Liao <lwlw1988@gmail.com>
2023-09-15 20:38:29 +02:00
3191349182 docs(format): set-formatter!: escape quotes in docstring 2023-09-14 20:17:24 +02:00
0b2e6d7070 docs(format): clarify how to update macro in private config 2023-09-14 20:06:51 +02:00
dd68bbb7da fix(format): removed unused argument 2023-09-13 20:21:08 +01:00
b0e579741e fix(format): react to ns change 2023-09-13 20:21:07 +01:00
3aa9796b84 fix(format): resolve list expansion issues
The argument list was being expanded incorrectly, this should now be resolved.
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
057e6c531c refactor: replace doom-enlist with ensure-list
doom-enlist is now a deprecated alias for ensure-list, which is built
into Emacs 28.1+ and is its drop-in replacement. We've already
backported it for 27.x users in doom-lib (in 4bf4978).

Ref: 4bf49785fd
2022-08-07 19:43:13 +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
bf488394e9 editor/format lsp feature requirement from textDocument/rangeFormatting to textDocument/formatting. 2021-07-27 17:49:57 +08:00
ad24061a81 Fix formatting ignoring buffer-local variables 2021-07-24 01:54:06 +10:00
9fb96f9eeb Fix 'setting-constant enable-multibyte-characters' error
Regression caused by 78dde6efd.

Mentioned in #5133
2021-06-04 22:45:36 -04:00
78dde6efdd Fix #5133: don't kill LSP after reformatting
This happened because LSP hooks on kill-buffer-hook (and possibly
others) caused our temporary formatting buffer to talk to LSP as if it
were the original buffer. When the temp buffer was cleaned up, LSP
assumed the original buffer had been closed. No more!

In fact, to avoid similar issues, let's avoid any complex functionality
in hooks in this temp buffer.
2021-06-04 22:22:57 -04: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
99a83ca18f A workaround for formatting org mode
If point is in a source block, format that source block.
Else don't try to format the buffer. format-all-buffer does not support
org mode.
2020-12-13 15:36:56 +01:00
dec573c4e5 Allow formatter in some "special" buffers
Like org-src-edit and scratch buffers.

Fixes #3905
Closes #3915
2020-11-03 21:26:07 -05:00
72da7a3f04 editor/format: add org src-block support
Src blocks can now be reformatted. `+format/buffer` will reformat the
whole src block at point. `+format/region` will format only the
selection (even a subset of a src block).

Closes #3484
2020-08-06 15:25:56 -04:00
da1030985d Minor refactors & reformatting 2020-07-23 01:26:03 -04:00
6798966f78 editor/format: Use eglot LSP formatter 2020-06-24 01:56:26 +09:00
991a205ebd Fix wrong-number-of-args error on +format/region-or-buffer 2020-06-13 00:43:48 -04:00
649052337b fix +format/region when formatting with LSP 2020-05-26 18:16:23 +03:00
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
4c61f22132 Fix #3175: don't format org-exported buffers
By inhibiting the formatter in temp or special buffers.
2020-05-20 04:46:37 -04:00
7472cffadd Integrate LSP into +format/{buffer,region} commands
Relevant to #1652
2020-05-08 22:04:59 -04:00