 contains a syntax error in isolation. It is mostly useful for formatting
 snippets or single lines."
   (interactive "rP")
-  (save-restriction
-    (narrow-to-region beg end)
-    (let ((+format-region-p t))
-      (+format/buffer))))
+  (if (and (bound-and-true-p lsp-mode)
+           (lsp-feature? "textDocument/rangeFormatting"))
+      #'lsp-format-region
+    (save-restriction
+      (narrow-to-region beg end)
+      (let ((+format-region-p t))
+        (+format/buffer)))))
 
 ;;;###autoload
 (defun +format/region-or-buffer ()

;;; Commands

;;;###autoload
(defalias '+format/buffer #'format-all-buffer)

;;;###autoload
(defun +format/region (beg end)

  (interactive)
  (call-interactively
   (if (doom-region-active-p)
       #'+format/region
     #'+format/buffer)))


;;
