DanielGavin / ols

Language server for Odin
MIT License
382 stars 58 forks source link

Question / feature request - when formatting, can newlines/carriage returns be made optional? Running into encoding issues. #308

Closed sortofsleepy closed 5 months ago

sortofsleepy commented 5 months ago

Hello!

Just getting started with Odin today. I'm using Emacs and Eglot on Windows and I'm running into a bit of an odd issue. Before I get into it, let me preface real quick that I'm a little new to using language servers like this so I might be misunderstanding how things are supposed to work and/or terminology, please bear with me.

Anyways, for the most part, the server works great so far with one exception - when I use the server to format the document, it adds carriage returns automatically. I imagine it's not a big deal for most but unfortunately on Windows, it ends up looking like this

Screenshot 2024-02-13 203451

I've tried changing the encoding settings within Emacs but nothing seems to work and no other projects on my computer using language servers exhibit this issue which leads me to think the issue/setting might be coming from the ols.

At the end of the day it's technically more of an annoyance and I can get by for now if I use an editorconfig file and force a line ending encoding on save. That said, it'd be great to match the behavior of other servers out there if possible.

I did try tweaking things a bit as I saw in format.odin that there seems to be options for newlines but again, I'm a bit new with Odin so I was probably just tweaking the wrong things.

Thanks! 🍻

DanielGavin commented 5 months ago

Hello!

It is something that can configured. Don't think it's interfaced currently through odinfmt.json

https://github.com/DanielGavin/ols/blob/7145764020fa463ee393b1f2701b1c151c162cce/src/odin/printer/printer.odin#L213

sortofsleepy commented 5 months ago

🎉 ah! I was wondering how the formatting was working, didn't think to look in that folder. Thanks for the quick response.

As a side note, I don't think watching out for CRLF is necessary these days any more; at least in my experience, I haven't run into any editors/ides that didn't already do some sort of automatic conversion to/from. Of course this is just me so I could be an edge case.

Anyways thank you!