elentok/format-on-save.nvim

clang-format

vishal340 opened this issue ยท 6 comments

does this support clang-format? i couldn't find a way to add additional formatters

Hi,

Yeah, it should support it.

Regarding "additional formatters", the whole point of this plugin was to allow adding whatever formatters you want via configuration. I added a few formatters just as examples (if anyone wants to send a PR to add existing formatters I'm happy to merge them).

Look at the "Configuration" section of the README file, it explains how to add whichever formatter you want.

i got it working. sorry about posting issue. I have never used null-ls or anything. very new to this.

All's good, no worries ๐Ÿ˜„
Thanks for the interest in my plugin and feel free to post again if you run into any issues ๐Ÿ‘

I got this working on my dotfiles with:

return formatters.shell({
  cmd = { "clang-format", "--assume-filename", "%" },
})

@elentok I am happy to PR support for this if you would like? Not sure on how you want to approach built in support for formatters. Thanks!

I got this working on my dotfiles with:

return formatters.shell({
  cmd = { "clang-format", "--assume-filename", "%" },
})

@elentok I am happy to PR support for this if you would like? Not sure on how you want to approach built in support for formatters. Thanks!

Hi Jack,

Sure, go ahead, thanks! ๐Ÿ‘

I was afraid at first that including formatter configuration might be difficult to maintain but I'm not worried anymore. I do think that I might have to split the formatters.lua file at some point, right now it's 67 lines but at some point it might get too big to easily maintain.

Hi,

I'm closing this issue for now, if anyone wants to send a PR to add clang-format to the built-in formatters, feel free ๐Ÿ˜„