From b168ff5ab50e5f6d6b7d826e53e14ba470319b6e Mon Sep 17 00:00:00 2001
From: Tsakiris Tryfon
Date: Thu, 28 Mar 2024 05:22:20 +0200
Subject: refactor: Rename clang_format to clang-format (#352)
This makes the formatter name consistent with the executable and also
with other tools like e.g. Mason, for better interoperability.
---
lua/conform/formatters/clang-format.lua | 22 ++++++++++++++++++++++
lua/conform/formatters/clang_format.lua | 26 ++++----------------------
2 files changed, 26 insertions(+), 22 deletions(-)
create mode 100644 lua/conform/formatters/clang-format.lua
(limited to 'lua')
diff --git a/lua/conform/formatters/clang-format.lua b/lua/conform/formatters/clang-format.lua
new file mode 100644
index 0000000..2e68fc1
--- /dev/null
+++ b/lua/conform/formatters/clang-format.lua
@@ -0,0 +1,22 @@
+local util = require("conform.util")
+---@type conform.FileFormatterConfig
+return {
+ meta = {
+ url = "https://www.kernel.org/doc/html/latest/process/clang-format.html",
+ description = "Tool to format C/C++/… code according to a set of rules and heuristics.",
+ },
+ command = "clang-format",
+ args = { "-assume-filename", "$FILENAME" },
+ range_args = function(self, ctx)
+ local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range)
+ local length = end_offset - start_offset
+ return {
+ "-assume-filename",
+ "$FILENAME",
+ "--offset",
+ tostring(start_offset),
+ "--length",
+ tostring(length),
+ }
+ end,
+}
diff --git a/lua/conform/formatters/clang_format.lua b/lua/conform/formatters/clang_format.lua
index 2e68fc1..72e545b 100644
--- a/lua/conform/formatters/clang_format.lua
+++ b/lua/conform/formatters/clang_format.lua
@@ -1,22 +1,4 @@
-local util = require("conform.util")
----@type conform.FileFormatterConfig
-return {
- meta = {
- url = "https://www.kernel.org/doc/html/latest/process/clang-format.html",
- description = "Tool to format C/C++/… code according to a set of rules and heuristics.",
- },
- command = "clang-format",
- args = { "-assume-filename", "$FILENAME" },
- range_args = function(self, ctx)
- local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range)
- local length = end_offset - start_offset
- return {
- "-assume-filename",
- "$FILENAME",
- "--offset",
- tostring(start_offset),
- "--length",
- tostring(length),
- }
- end,
-}
+-- This was renamed to clang-format
+local conf = vim.deepcopy(require("conform.formatters.clang-format"))
+conf.meta.deprecated = true
+return conf
--
cgit v1.2.3-70-g09d2