-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
refactor(format): replace with apheleia #6369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(format): replace with apheleia #6369
Conversation
9476d25 to
0ce5b74
Compare
2db3b18 to
9fb9872
Compare
25448d5 to
0061b26
Compare
613dccd to
6b70908
Compare
cf8bbe4 to
4b43b59
Compare
a586625 to
af77f7d
Compare
4b07aec to
9e11279
Compare
645f902 to
0e94af6
Compare
|
@yufengwang As mentioned in the new documentation for the |
|
okay, is there any workaround? because i highly depend on |
With this tweak, it seems to be working for me. Note, the @@ -8,7 +8,7 @@
(defun +format-region (start end &optional callback)
"Format from START to END with `apheleia'."
- (when-let* ((command (apheleia--get-formatter-command
+ (when-let* ((command (apheleia--get-formatters
(if current-prefix-arg
'prompt
'interactive)))
@@ -23,7 +23,7 @@
;; Ensure this temp buffer seems as much like the origin buffer as
;; possible, in case the formatter is an elisp function, like `gofmt'.
(cl-loop for (var . val)
- in (cl-remove-if-not #'listp (buffer-local-variables origin-buffer))
+ in (cl-remove-if-not #'listp (buffer-local-variables cur-buffer))
;; Making enable-multibyte-characters buffer-local causes an
;; error.
unless (eq var 'enable-multibyte-characters)
@@ -45,7 +45,9 @@
;; restore indentation without affecting new
;; indentation
(indent-rigidly (point-min) (point-max)
- (max 0 (- indent (+format--current-indentation))))))
+ (max 0 (- indent (+format--current-indentation)))))
+ (set-buffer-modified-p nil)
+ )
(with-current-buffer cur-buffer
(delete-region start end)
(insert-buffer-substring-no-properties formatted-buffer) |
|
In future, please use issues when reporting issues. As for this change, I've tested it locally and it seems to "kind of" work but since as pointed out it's not supported upstream, if you're happy with this fix I'll PR it in. |
|
@elken thank you for the work on this; it's working well for me, and I'm glad to have it in main. |
|
@elken thanks for your hard work |
Doom-provided formatting tools now support `prettier` out-of-the-box as of doomemacs/doomemacs#6369
|
@yufengwang Hey! Please tell me how you got region formatting working. If I don't modify any settings If I add I'm on latest master and the doom code does contain the changes above. |
|
a) if you're having issues, report them through the proper channels |
`apheleia--indent-lisp-buffer` does not exist. Ref: doomemacs#6369
`apheleia--indent-lisp-buffer` does not exist. Ref: doomemacs#6369
|
|
||
|
|
||
| ;; | ||
| ;;; Commands | ||
|
|
||
| (defun +format--org-region (beg end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elken You may have removed the +format--org-region for some reason, but this is quite handy and, as far as I am concerned, I use it every day. Can i add it back in this module?
close doomemacs#6369#discussion_r1441274403
close doomemacs#6369#discussion_r1441274403
close doomemacs#6369#discussion_r1441274403
close doomemacs#6369#discussion_r1441274403
close doomemacs#6369#discussion_r1441274403
Replace format-all with apheleia to grealy simplify the formatting setup.
For the most part, this is a low degree of ready the only thing missing is documentation and more granular testing on each module.
I've also had a recent thought on how to handle LSP formatters, previously I ignored them in favour of apheleia but I might forward-port the same logic here for the new module.