Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rename clang_format to clang-format #352

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion doc/conform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions lua/conform/formatters/clang-format.lua
Original file line number Diff line number Diff line change
@@ -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,
}
26 changes: 4 additions & 22 deletions lua/conform/formatters/clang_format.lua
Original file line number Diff line number Diff line change
@@ -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
Loading