Commit graph

59 commits

Author SHA1 Message Date
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
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
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
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
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
c795a988e6
Conform many modules to new conventions 2019-07-23 12:30:47 +02:00
Henrik Lissner
9bba39bd3a
Prevent unsaved prompts when formatting #1498
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.
2019-06-16 19:16:22 +02:00
Henrik Lissner
13f5a76278
Fix formatters unable to find project root #1489 2019-06-13 18:01:45 +02:00
argo
12233811a8 fix: format-all upstream definitions
Upstream renamed definitions in
f3ed09c430 .
2019-06-08 17:45:42 +02:00
Henrik Lissner
0c743afcfd
editor/format: remove utf-8 conversion on Windows #914 2019-05-30 14:11:53 -04:00
Henrik Lissner
77e4cc4d58
💥 Remove :feature category
:feature was a "catch-all" category. Many of its modules fit better in
other categories, so they've been moved:

- feature/debugger -> tools/debugger
- feature/evil -> editor/evil
- feature/eval -> tools/eval
- feature/lookup -> tools/lookup
- feature/snippets -> editor/snippets
- feature/file-templates -> editor/file-templates
- feature/workspaces -> ui/workspaces

More potential changes in the future:

- A new :term category for terminal emulation modules (eshell, term and
  vterm).
- A new :os category for modules dedicated to os-specific functionality.
  The :tools macos module would fit here, but so would modules for nixos
  and arch.
- A new :services category for web-service integration, like wakatime,
  twitter, elfeed, gist and pastebin services.
2019-04-24 18:16:04 -04:00
Henrik Lissner
5c3188afd5
editor/format: fix +format/region-or-buffer
The `r` interactive spec barfs an error if no mark is active, preventing
this function from ever calling `+format/buffer`.

Reported by @amosbird
2019-04-02 00:52:10 -04:00
Henrik Lissner
f6cc2644b0
New doom-log macro for debug-time logging
doom-log won't interfere with the minibuffer if it's in use, and will
report the originating module.

Addresses #1215
2019-03-04 18:38:25 -05:00
Henrik Lissner
99fd8b4e1b
O'byte-compiler
Who forbade the obsolete,
Hooks, functions; adieu.

(And an unused argument too)
2019-02-03 18:42:09 -05:00
Henrik Lissner
09603c5444
+format-region-p = nil
Should be a boolean in the first place; this fixes custom formatters
that use it like a boolean.
2018-10-19 11:48:47 -04:00
Edwin Török
e5ff6c8418 fix +format--set error path
In +format--set:
../modules/editor/format/autoload/settings.el:81:26:Warning: ‘error’ called
    with 0 args to fill 1 format field(s)

Signed-off-by: Edwin Török <edwin@etorok.net>
2018-10-04 00:38:05 +01:00
Edwin Török
6859f77e1d format.el: fix Wrong type argument: listp, t
The intention here was to build a list of two elements.

Signed-off-by: Edwin Török <edwin@etorok.net>
2018-10-03 23:03:11 +01: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
c52d2a5a14
editor/format: add +format-type letvar
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.
2018-09-10 08:25:48 -04:00
Henrik Lissner
e0f8325f45
editor/format: fix wrong-number-of-args error
+format|buffer takes no arguments
2018-09-10 08:25:48 -04:00
Henrik Lissner
e38e79e6d7
editor/format: fix not-a-function error
Because unquoted lists were being evaluated, it was treated as a
function call.
2018-09-10 08:25:48 -04:00
Henrik Lissner
f6234e463a
editor/format: rewrite set-formatter!
+ First argument is no longer a major mode or list thereof, it is NAME.
  Use :modes instead.
+ Updated docstring & examples.
+ Added formatting unsetting: (set-formatter! 'some-formatter nil)
2018-09-09 09:58:23 -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
46083ed398
editor/format: preserve indent in +format-buffer 2018-09-09 09:58:22 -04:00
Henrik Lissner
c58077810d
General refactor of modules
General code and comment improvements.

Also, removed the :desc's for csv-mode because map! is currently unable
to set which-key descriptions mode-locally, and should be avoided for
anything but global keybinds. This will be fixed when General is
introduced into Doom.
2018-09-09 09:58:20 -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
df42d8ce89
editor/format: rewrite & fix set-formatter!
+ Updated docstring (and added two more examples)
+ Can now be used with shell command strings or string lists. String
  sublists can have more than 2 elements. Non-string items will be
  interpolated into the string before it. If any non-string item is nil,
  its sublist is omitted entirely.
+ Can now be used to redefine formatters predefined by the format-all
  package, by passing the formatter's name (as a symbol) as the first
  argument.
+ Added :modes property for cases when first argument isn't a major mode
  or list of them (when redefining a formatter).
2018-09-03 03:58:44 +02:00
Henrik Lissner
81ee563c4c
+format|buffer: use pcase-let & return boolean
So it can be used in other functions.
2018-09-03 03:58:43 +02:00
Henrik Lissner
75b39a9396
editor/format: preserve indentation for regions 2018-09-03 03:58:43 +02:00
Henrik Lissner
c885cd2b9d
editor/format: refactor & reformat +format-buffer
Also switches cl-destructuring-bind to pcase-let to avoid breaking
errors being thrown.
2018-09-03 03:58:43 +02:00
Henrik Lissner
349fb49c7b
editor/format: refactor +format-buffer & users 2018-08-30 15:00:33 +02:00
Henrik Lissner
1b4040229e
editor/format: update documentation 2018-08-30 14:56:50 +02:00
Henrik Lissner
1ae3523f75
editor/format: autoload format-all-probe #834 2018-08-30 14:44:37 +02:00