From 1efcf49c1e603155902cd09711e44ce0e419e5d5 Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:31:25 +0200 Subject: [PATCH] feat(supressFormatter): support for `clang-format` --- README.md | 4 +++- lua/rulebook/data/suppress-formatter-comment.lua | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f6ce8bc..489ef67 100644 --- a/README.md +++ b/README.md @@ -97,10 +97,12 @@ missing. - [yamllint](https://yamllint.readthedocs.io/en/stable/disable_with_comments.html) + ### Suppress Formatting - [stylua](https://github.com/JohnnyMorganz/StyLua#ignoring-parts-of-a-file) - [prettier](https://prettier.io/docs/en/ignore.html) -- [black](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#ignoring-sections) +- [black](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#ignoring-sections) / [ruff](https://docs.astral.sh/ruff/formatter/#format-suppression) +- [clang-format](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code) ## Installation This plugin requires diagnostics provided by a source that supports Neovim's diff --git a/lua/rulebook/data/suppress-formatter-comment.lua b/lua/rulebook/data/suppress-formatter-comment.lua index 27abf0d..6bb2a28 100644 --- a/lua/rulebook/data/suppress-formatter-comment.lua +++ b/lua/rulebook/data/suppress-formatter-comment.lua @@ -55,6 +55,18 @@ M = { ignoreRange = { "", "" }, docs = "https://prettier.io/docs/en/ignore.html#markdown", }, + c = { + ignoreBlock = { "/* clang-format off */", "/* clang-format on */" }, + location = "encloseLine", + ignoreRange = { "/* clang-format off */", "/* clang-format on */" }, + docs = "https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code", + }, + cpp = { + ignoreBlock = { "/* clang-format off */", "/* clang-format on */" }, + location = "encloseLine", + ignoreRange = { "/* clang-format off */", "/* clang-format on */" }, + docs = "https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code", + }, } --------------------------------------------------------------------------------