From 77f0a66d2fb65ce4a447b2f2481c489c2a8e231f Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sat, 6 Aug 2022 12:35:29 +0200 Subject: [PATCH] Documentation: Add clang-format variant to EmacsConfiguration.md Add a variant of auto formatting using clang-format that doesn't use additional packages. It works by adding a buffer-local hook to `'before-save` for all C++ project files. --- Documentation/EmacsConfiguration.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/EmacsConfiguration.md b/Documentation/EmacsConfiguration.md index bcf9d2afc8a..1abcc882f8d 100644 --- a/Documentation/EmacsConfiguration.md +++ b/Documentation/EmacsConfiguration.md @@ -54,4 +54,10 @@ There are multiple packages to handle auto formatting with - [format-all-mode](https://github.com/lassik/emacs-format-all-the-code) - [clang-format-plus](https://github.com/SavchenkoValeriy/emacs-clang-format-plus) +Alternatively, this can be done without additional packages, using `lsp-mode`. +You can use the following `.dir-locals.el` file placed in the project root: + +```lisp +((c++-mode + (eval add-hook 'before-save-hook #'lsp-format-buffer nil t))) ```