Open jasonboukheir opened 5 years ago
Reading the uncrustify documentation, it looks like you can override the language with the -l
flag. I'm not familiar with scripting vim, but I could try creating a pull request this weekend with a fix that supplies the file type when calling uncrustify.
so instead of
uncrustify --no-backup < $FILENAME
we'd call something like
uncrustify --no-backup -l $LANGUAGE_TYPE < $FILENAME
You should be able to fix it by using:
autocmd FileType cs let g:ale_c_uncrustify_options = '-l CS'
Unfortunately I'm not sure of a good solution to do this for every language without a switch for each potential filetype, which could change if uncrustable begins supporting more things. If there's a "file name" option (like --stdin-filename or something similar) that would be very helpful.
Lol Perfect timing. I had just found those options. Thanks so much!
Closing this issue.
Reopening for the time being until we get an automated solution, through flag or otherwise.
uncrustify -f example.cs
treats the filetype correctly with CS and outputs to stdout. I'll try it with other filetypes.
Does that treat it like the stdin filename but still read from the stdin? If so, that should work for most filetypes.
I'm not sure I understand the question, but unfortunately, if the architecture is forcing us to feed it with < filename
then it looks like it won't work without roundabout hacks.
if we can pass in just the filename to the executable, instead of using stdin on the contents of the file, the -f
option would work.
We can't use a filename or that would mean ALE would only work when the file is saved. I can't find any documentation on this, so I'm not sure what to do at this point.
I'm okay with just adding some code to automatically determine the filetype flag to send to uncrustify
. It supports 8 languages, so it wouldn't be too difficult.
See the prettier
fixer for somewhat similar code.
Information
VIM version 8.0
Operating System Ubuntu 18.04 WSL
Uncrustify Version Uncrustify-0.66.1_f
What went wrong
Using ALEFix on my .cs file with uncrustify was causing strange problems due to it being treated as a C file rather than CS file. One example is the string interpolation operator.
$"some string text";
=>$ "some string text";
Uncrustify incorrectly adds a space around the
$
symbol.Reproducing the bug
example.cs
example.cs
in vim:ALEFix
However, I'm pretty sure it's visible with these two commands:
uncrustify --no-backup < example.cs
v.s.uncrustify --no-backup example.cs
:ALEInfo
ALEInfo