Commit Graph

39 Commits

Author SHA1 Message Date
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
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
46083ed398 editor/format: preserve indent in +format-buffer 2018-09-09 09:58:22 -04:00
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
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
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
81ee563c4c +format|buffer: use pcase-let & return boolean
So it can be used in other functions.
2018-09-03 03:58:43 +02:00
75b39a9396 editor/format: preserve indentation for regions 2018-09-03 03:58:43 +02:00
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
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
349fb49c7b editor/format: refactor +format-buffer & users 2018-08-30 15:00:33 +02:00
1b4040229e editor/format: update documentation 2018-08-30 14:56:50 +02:00
1ae3523f75 editor/format: autoload format-all-probe #834 2018-08-30 14:44:37 +02:00
7616316634 editor/format: improve message feedback
Announce failures, noops and successes clearly, and log errors.
2018-08-30 13:29:49 +02:00
fd9a3c36ee editor/format: refactor (again) 2018-08-29 17:02:49 +02:00
6e03ddacda Update & revise set-formatter! docstring 2018-08-29 15:56:59 +02:00
4b9233bec7 editor/format: format by diff & major refactor
This redesigns how format-all applies changes. Before, it would erase
the buffer and insert the formatted result. This would throw markers out
of whack, and usually meant the cursor would end up somewhere else (e.g.
the beginning of the file).

Now, changes are made to the buffer line by line, via RCS patch.

Other changes:

+ +format-region function was removed (replaced by +format-buffer and
  +format/region).
+ set-formatter! was moved to autoload/settings.el
+ New +format/buffer command to replace format-all-buffer
2018-08-29 12:48:38 +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
2b560a6a0e General & minor refactoring 2018-08-28 13:36:44 +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
98b5c95ee5 editor/format: add +format|enable-on-save alias 2018-08-27 10:30:31 +02:00
3b69045ed4 editor/format: add +format|on-save buffer-locally 2018-08-26 17:31:14 +02:00
f1460ff592 editor/format: don't move cursor on save 2018-08-26 17:26:54 +02:00
6515a1c539 editor/format: fix +onsave 2018-08-25 01:10:47 +02:00
171c87aa2c editor/format: general fix & refactor
+ Fixes function/command formatters (like #'gofmt)
+ Fixes formatting by region
+ Adds default keybindings:
  + gQ evil operator
  + SPC c f (normal mode) to format buffer
  + SPC c f (visual mode) to format selection
2018-08-25 00:06:12 +02:00
8e7a7c1878 Fix void-function format-all-resolve-system error
This function is only defined at compile time for the format-all
package, so we must extract it into a new function.
2018-08-22 20:38:16 +02:00
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
8d26879f99 Add :editor multiple-cursors module
Moves evil-mc/evil-multiedit out of feature/evil.
2018-08-06 00:31:23 +02:00
5531d7115a Fix indentation for many autodef setters 2018-06-22 01:49:21 +02:00
3a3eb92087 Move :tools rotate-text to :editor rotate-text
This change was a long time coming.
2018-06-22 01:49:20 +02:00
b0f1804799 Unbind double-quote in lisp-mode
Causes double-double-quoting. smartparens will handle it.
2018-06-20 22:58:05 +02:00
6426da3533 Fix :hook modes for parinfer-mode 2018-06-13 16:53:44 +02:00
63552338ec Conform editor/parinfer to Doom conventions
+ Use evil +everywhere flag for universal evil integration,
+ Use :hook instead of `add-hook!` and implicit lambda,
+ Fix path in header.
2018-06-12 21:34:47 +02:00
db45248adf Add yasnippet back to parinfer 2018-06-11 21:55:34 +10:00
3fec00a534 Swap from emacs-lisp-mode-map to parinfer-mode-map 2018-06-11 10:10:34 +10:00
d178d78b2b Move +parinfer to :editor parinfer 2018-06-11 10:09:37 +10:00