From 200ab5b9afc5cfe4ea83e5cbac4e444fd189f077 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 6 May 2020 16:29:32 -0400 Subject: [PATCH] Fix #3054: format with lsp only if server is capable And fall back to format-all otherwise. --- modules/editor/format/autoload/format.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/editor/format/autoload/format.el b/modules/editor/format/autoload/format.el index 9229c5a1c..bbc701ff0 100644 --- a/modules/editor/format/autoload/format.el +++ b/modules/editor/format/autoload/format.el @@ -219,13 +219,15 @@ snippets or single lines." is selected)." (interactive) (call-interactively - (if (bound-and-true-p lsp-mode) - (if (doom-region-active-p) + (if (doom-region-active-p) + (if (and (bound-and-true-p lsp-mode) + (lsp-feature? "textDocument/rangeFormatting")) #'lsp-format-region - #'lsp-format-buffer) - (if (use-region-p) - #'+format/region - #'+format/buffer)))) + #'+format/region) + (if (and (bound-and-true-p lsp-mode) + (lsp-feature? "textDocument/formatting")) + #'lsp-format-buffer + #'+format/buffer))) ;;