crisidev / bacon-ls

A Language Server for Rust using Bacon diagnostics
https://github.com/crisidev/bacon-ls
MIT License
18 stars 0 forks source link

Issue spans are inaccurate #2

Open CorvusPrudens opened 6 days ago

CorvusPrudens commented 6 days ago

Warning or error spans as displayed in the editor are inaccurate. Compare the representation in the editor:

ide-error

To the representation in the terminal:

terminal-error

It's not so bad when the error is simple like the above, but it can be tricky to parse what's going on when multiple, separate spans appear on one or more lines.

Of course, the limitation here comes from bacon itself. The locations export provides no way to get at the underlying span information beyond a single line and column. As far as I can tell, this isn't insurmountable, but simply a result of directly parsing the human-readable output of cargo check, rather than consuming the JSON formats.

As far as I can tell, this has never been brought up in bacon's repo. I don't know how feasible such a change would be, but at the very least I think this demonstrates a clear use case.

crisidev commented 4 days ago

Thanks for opening this issue.

As you noticed, the limitation comes from bacon itself. Parsing the JSON format would probably help a lot here and it is a while that I am thinking of trying to stub a very basic implementation of something that runs cargo check|build|clippy directly inside the language server and parse the JSON to get proper spans.

I will probably have some time in November to try to build a POC for this. Maybe we can also open a similar issue to the bacon repo and link it to this one?