Add +format-with-lsp variable
To control whether or not to use LSP code formatter when it is available.
This commit is contained in:
parent
885197bd06
commit
090a68ab8f
2 changed files with 10 additions and 2 deletions
|
@ -206,7 +206,8 @@ See `+format/buffer' for the interactive version of this function, and
|
|||
"Reformat the current buffer using LSP or `format-all-buffer'."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(if (and (bound-and-true-p lsp-mode)
|
||||
(if (and +format-with-lsp
|
||||
(bound-and-true-p lsp-mode)
|
||||
(lsp-feature? "textDocument/formatting"))
|
||||
#'lsp-format-buffer
|
||||
#'format-all-buffer)))
|
||||
|
@ -219,7 +220,8 @@ WARNING: this may not work everywhere. It will throw errors if the region
|
|||
contains a syntax error in isolation. It is mostly useful for formatting
|
||||
snippets or single lines."
|
||||
(interactive "rP")
|
||||
(if (and (bound-and-true-p lsp-mode)
|
||||
(if (and +format-with-lsp
|
||||
(bound-and-true-p lsp-mode)
|
||||
(lsp-feature? "textDocument/rangeFormatting"))
|
||||
#'lsp-format-region
|
||||
(save-restriction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue