aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTsakiris Tryfon <tr.tsakiris@gmail.com>2024-03-28 05:22:20 +0200
committerGitHub <noreply@github.com>2024-03-27 20:22:20 -0700
commitb168ff5ab50e5f6d6b7d826e53e14ba470319b6e (patch)
treec2ffd99d0960d89e90ce136107c2a3006538424d
parent96b86751eb4c716eb17df1ee2ad815ff3e24ef79 (diff)
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.
-rw-r--r--README.md2
-rw-r--r--doc/conform.txt2
-rw-r--r--lua/conform/formatters/clang-format.lua22
-rw-r--r--lua/conform/formatters/clang_format.lua26
4 files changed, 28 insertions, 24 deletions
diff --git a/README.md b/README.md
index 1c5e0d5..af9311b 100644
--- a/README.md
+++ b/README.md
@@ -197,7 +197,7 @@ You can view this list in vim with `:help conform-formatters`
- [buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier) - buildifier is a tool for formatting bazel BUILD and .bzl files with a standard convention.
- [cabal_fmt](https://hackage.haskell.org/package/cabal-fmt) - Format cabal files with cabal-fmt
- [cbfmt](https://github.com/lukas-reineke/cbfmt) - A tool to format codeblocks inside markdown and org documents.
-- [clang_format](https://www.kernel.org/doc/html/latest/process/clang-format.html) - Tool to format C/C++/… code according to a set of rules and heuristics.
+- [clang-format](https://www.kernel.org/doc/html/latest/process/clang-format.html) - Tool to format C/C++/… code according to a set of rules and heuristics.
- [cljstyle](https://github.com/greglook/cljstyle) - Formatter for Clojure code.
- [cmake_format](https://github.com/cheshirekow/cmake_format) - Parse cmake listfiles and format them nicely.
- [codespell](https://github.com/codespell-project/codespell) - Check code for common misspellings.
diff --git a/doc/conform.txt b/doc/conform.txt
index 2716927..e2fb63d 100644
--- a/doc/conform.txt
+++ b/doc/conform.txt
@@ -203,7 +203,7 @@ FORMATTERS *conform-formatter
with a standard convention.
`cabal_fmt` - Format cabal files with cabal-fmt
`cbfmt` - A tool to format codeblocks inside markdown and org documents.
-`clang_format` - Tool to format C/C++/… code according to a set of rules and
+`clang-format` - Tool to format C/C++/… code according to a set of rules and
heuristics.
`cljstyle` - Formatter for Clojure code.
`cmake_format` - Parse cmake listfiles and format them nicely.
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