stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.72k stars 142 forks source link

refactor: Rename clang_format to clang-format #352

Closed tsakirist closed 4 months ago

tsakirist commented 4 months ago

Scope

This makes the formatter name consistent with the executable and also with other tools like e.g. Mason, for better interoperability.

Why

One use-case is to be able to automatically install formatters that are registered with other tools like Mason.

local registered_formatters = require("conform").list_all_formatters()
for _, formatter in ipairs(registered_formatters) do
   MasonInstall(formatter) -- Asume a MasonInstall function exists
end
stevearc commented 4 months ago

Sure, seems fine to me

FIONover commented 2 months ago

nope, it isn't fine @stevearc try to customize formatter)

require("conform").formatters.clang-format = { prepend_args = {"--style", "{ BasedOnStyle: LLVM, IndentWidth: 4 }"}, }

tsakirist commented 2 months ago

nope, it isn't fine @stevearc try to customize formatter)

require("conform").formatters.clang-format = { prepend_args = {"--style", "{ BasedOnStyle: LLVM, IndentWidth: 4 }"}, }

You can index the formatters table with: require("conform").formatters["clang-format"] = { prepend_args = {"--style", "{ BasedOnStyle: LLVM, IndentWidth: 4 }"} }

FIONover commented 2 months ago

Oh thanks <3 I'm not that good at lua, I think it should be mentioned somewhere for people like me