Closed Maypher closed 4 days ago
Not the solution you're looking for but you can add a .clang-format
to your home dir with the following content
BasedOnStyle: google
TabWidth: 4
IndentWidth: 4
ColumnLimit: 100
# Other languages JavaScript, Proto
Language: Cpp
No need for that, I figured it out. Turns out that conform looks for an exact match when setting formatters_by_ft
and formatters
so when setting the file-type to clang-format
and the formatter option to clang_format
(since I can't use -
in dict keys) it took them as two different things.
I solved it by setting the formatter_by_ft
for c and cpp to clang_format
and the on formatter options I give it a custom command with the correct options.
opts = {
log_level = vim.log.levels.DEBUG,
formatters_by_ft = {
c = { "clang_format" },
cpp = { "clang_format" },
},
formatters = {
clang_format = {
command = "clang-format",
append_args = function()
return { "--style={BasedOnStyle: Google, IndentWidth: 4}" }
end
}
Neovim version (nvim -v)
NVIM v0.10.1
Operating system/version
Windows 11
Read debugging tips
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
Describe the bug
I'm running clang-format which I installed through mason.nvim with lazy.nvim
I believe the default style it's using is Google but it uses two spaces for indentation and I prefer using 4 so I added an argument to change the indent width
In
formatters
I edit theclang_format
config to append the arguments to it. However, as can be seen in the log file these arguments are nowhere to be found so the file gets formatted with 2 indent spaces. I'm not sure if it's an issue with conform or if it's because the formatter is installed through MasonWhat is the severity of this bug?
minor (annoyance)
Steps To Reproduce
--style={BasedOnStyle: Google, IndentWidth: 4}
.Expected Behavior
Line indentation should have 4 spaces, instead it has 2.
Minimal example file
Minimal init.lua
Additional context
No response