sbdchd / neoformat

:sparkles: A (Neo)vim plugin for formatting code.
BSD 2-Clause "Simplified" License
1.97k stars 188 forks source link

C# clang-format with Microsoft style broken #454

Closed ShinyZero0 closed 1 year ago

ShinyZero0 commented 1 year ago

I have redefined the clangformat for C# like this:

let g:neoformat_cs_clangformat = {
     \ 'exe': 'clang-format',
     \ 'args': ['--style=Microsoft', '--assume-filename=.cs'],
     \ }

Also i tried to create the same as a custom formatter. Anyway, even if i format the whole buffer, the result differs from manually running the exact same command on a file. E.g. i get the broken lambdas:

output.ForEach(p = > Console.WriteLine(p));

and some cursed public keywords placement while the tabstop is 4

public
class Program
{
  public
    static void Main(string[] args)
    {}
}

and broken string interpolation like this

Console.WriteLine($ "Var: {var}");

when i run the same command from shell, i don't get these issues and formatting is good

ShinyZero0 commented 1 year ago

Fixed, --assume-filename isn't working without stdin so it recognized the file as C code for some reason (i thought neoformat tempfile saves the extension). With stdin = 1 in neoformat it works well.