Commit graph

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

Mentioned in #5133
2021-06-04 22:45:36 -04:00
Henrik Lissner
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
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
027dec3b5f editor/format: use unabbreviated commit
Fix #5136
2021-06-04 14:08:42 -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
Sam Whitlock
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
Henrik Lissner
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
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
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
Henrik Lissner
d41df5f2c2
editor/format: add README #1166 2020-07-25 23:24:38 -04:00
Henrik Lissner
da1030985d
Minor refactors & reformatting 2020-07-23 01:26:03 -04:00
Seong Yong-ju
6798966f78 editor/format: Use eglot LSP formatter 2020-06-24 01:56:26 +09:00
Henrik Lissner
991a205ebd
Fix wrong-number-of-args error on +format/region-or-buffer 2020-06-13 00:43:48 -04:00
Tudor Roman
649052337b
fix +format/region when formatting with LSP 2020-05-26 18:16:23 +03:00
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
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
Henrik Lissner
7472cffadd
Integrate LSP into +format/{buffer,region} commands
Relevant to #1652
2020-05-08 22:04:59 -04:00
Henrik Lissner
0f696ec8b3
Merge pull request #3017 from sei40kr/fix-set-formatter
Fix set-formatter! documentation
2020-05-07 03:19:00 -04:00
Henrik Lissner
9a628c7a12
Fix missing paren in +format/region-or-buffer #3054
Because I'm a derp
2020-05-06 16:43:42 -04:00
Henrik Lissner
200ab5b9af
Fix #3054: format with lsp only if server is capable
And fall back to format-all otherwise.
2020-05-06 16:29:32 -04:00
Henrik Lissner
da2247e3d6
Remove redundant +default/lsp-format-region-or-buffer command 2020-05-06 15:14:16 -04:00
James Ravn
300bc65918
Use lsp-format-region-or-buffer if available
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.
2020-05-05 09:52:44 +01:00
Seong Yong-ju
e29e20cc52 Fix set-formatter! documentation
Remove :install from supported keywords.
2020-05-01 13:08:28 +09:00
Seong Yong-ju
7d1093dc29 Fix region formatting 2020-03-26 22:49:00 +09:00
Henrik Lissner
c049ada61c
Revert to lassik/emacs-format-all-the-code@47d862d
From lassik/emacs-format-all-the-code@8c8c47a

Fixes #2704
2020-03-11 00:57:44 -04:00
Henrik Lissner
c2a0ac8b3e
Fix #2605: update editor/format module 2020-03-10 01:48:20 -04:00
Henrik Lissner
4680f23d90
Fix type listp error when formatting buffers
Because `buffer-local-variables` may contain symbols
(which represent locally unbound variables), not just sublists.
2020-02-18 14:37:15 -05:00
Henrik Lissner
65b2d50e05
Bump to lassik/emacs-format-all-the-code@f57a2a8
From lassik/emacs-format-all-the-code@d126830
2020-02-06 15:20:27 -05:00
Henrik Lissner
a9402cfb55
Fix #2373: bring back package pinning
This needs some serious refactoring...
2020-01-25 19:02:00 -05:00
Janfel
2fe3268dc2 Fix cl-loop indentation. 2020-01-20 17:17:37 +01:00
Janfel
e34b5decc6 Remove unused local bindings
Remove the let-clauses binding origin-buffer-file-name and origin-default-directory, as the previous commit renders them obsolete.
2020-01-20 17:17:37 +01:00
Janfel
2e82f297f6 Fix #2036: Copy local variables into formatting buffer.
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.
2020-01-20 17:17:37 +01:00
Henrik Lissner
4cc14389e8
PIN ALL THE PACKAGES 2020-01-14 22:32:11 -05:00
Janfel
9b5835504e
Fix #2349: Make +format-completing-read return symbol
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.
2020-01-10 21:14:03 +01:00
Henrik Lissner
d1beb47e90
Fix invalid-function 116 when formatting with tidy
Due to refactor upstream: lassik/emacs-format-all-the-code@4f458bd
2020-01-04 03:33:42 -05: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