codespan icon indicating copy to clipboard operation
codespan copied to clipboard

codespan-reporting and codespan-lsp compatibility

Open aweary opened this issue 5 years ago • 4 comments

I've been using codespan and codespan-reporting for error reporting for my CLI. I'm now working on an LSP extension and want to use codespan-lsp to covert to the proper LSP types, but it seems like codespan-reporting doesn't play well.

For example, I have a custom file system abstraction that implements the Files trait but codespan-lsp utilities like byte-span-to-range expect a reference to codespan::Files. They also expect a Span but codespan-reporting's Label uses Range<usize>.

Are there plans to align the packages one way or the other, or should I just roll my own diagnostics object and have compatibility layers for codespan-reporting and codespan-lsp?

aweary avatar Apr 06 '20 17:04 aweary

Thanks for your issue!

I've been trying hard to de-emphasise codespan, and emphasizing codespan-reporting, because I've found it rather challenging to create a one-size-fits all thing for handling files. This was part of the work I did in inverting the dependency between those two crates. Eventually I'd like to deprecate codespan, if I'm honest.

codespan-lsp currently depends on codespan though, so sadly you are tied to using codespan if you want these conversions. It would be cool if there would be some way to make those conversions easier to implement for custom file system abstractions though! I'm still not sure where they fit though…

brendanzab avatar Apr 07 '20 02:04 brendanzab

@brendanzab would you be open to including some LSP utilities in codespan-reporting? It might make sense to have codespan_reporting::lsp to mirror the codespan_reporting::term backend. I'd be happy to help here if you're interested.

aweary avatar Apr 07 '20 04:04 aweary

Ohhh, that is a good idea, yes! Now I have a better handle on the lsp-types version ranges this could also be helpful too - it was a constant pain to keep having to update them.

brendanzab avatar Apr 07 '20 09:04 brendanzab

I'd definitely be open to collaborating on this! Feel free to chat on Gitter or the the #langdev channel on the rust community discord if you like!

brendanzab avatar Apr 07 '20 09:04 brendanzab