Describe the feature
The basic idea has been introduced to format-all-the-code in https://github.com/lassik/emacs-format-all-the-code/issues/47. The assumption is that a language server probably has a better idea how to format the code than any default set in format-all-the-code. The proposal, quoted from there, goes like this:
lsp-mode is not enabled for the current buffer, fallback to the current behaviour.textDocument/formatting capability of the current language server (or maybe servers, since that's apparently a supported workflow). If it's not available, fallback to current behaviour.textDocument/formatting (probably via lsp-format-buffer) instead of the predefined tool.It's not clear whether it's a better idea to make format-all-the-things LSP-aware or extend doom-emacs' auto-formatting wrapper. Either way I'd be happy to have the feature.
System information
Sorry for the late response; just chiming in to let you know I am aware of this issue. The :editor format module is painfully overdue a rewrite, both to make it LSP-aware, and possibly to replace format-all-the-code with reformatter.el to facilitate a more customizable formatting backend.
I don't yet have time to work on this, however, but I haven't forgotten about it.
Also, @Kaali in #2516 brought up this LSP-unawareness in go-mode. For the time being, the workaround for this is to disable our formatter by adding go-mode to +format-on-save-enabled-modes (which is a negated list, by default, due to its first element being not), then add lsp-format-buffer to that mode's local before-save-hook. e.g.
(add-to-list '+format-on-save-enabled-modes 'go-mode t)
(add-hook! 'go-mode-hook
(add-hook 'before-save-hook #'lsp-format-buffer nil 'local)
(add-hook 'before-save-hook #'lsp-organize-imports nil 'local))
@hlissner Thanks for the feedback! Before you replace format-all-the-code, you might be interested in recent developments, which introduces global and buffer-local configurable formatters. Otherwise: don't mind me, I'll be happy if and when it's done, but I'm also quite happy with Doom right now even without it :)
As of 7472cff, our format commands support LSP (if the running server supports formatting).
This can be disabled globally with
(setq +format-with-lsp nil)
Or on a per-mode basis with
(setq-hook! 'python-mode-hook +format-with-lsp nil)
In any case I'll consider this resolved. Thanks for bringing it to my attention!
Most helpful comment
Sorry for the late response; just chiming in to let you know I am aware of this issue. The
:editor formatmodule is painfully overdue a rewrite, both to make it LSP-aware, and possibly to replace format-all-the-code with reformatter.el to facilitate a more customizable formatting backend.I don't yet have time to work on this, however, but I haven't forgotten about it.
Also, @Kaali in #2516 brought up this LSP-unawareness in go-mode. For the time being, the workaround for this is to disable our formatter by adding
go-modeto+format-on-save-enabled-modes(which is a negated list, by default, due to its first element beingnot), then addlsp-format-bufferto that mode's local before-save-hook. e.g.